I have a dropdown in HTML code which I am populating using angular. I want the selected value of that dropdown and send it to angular so that angular fetch the data from database and populate in same HTML page. Below is my code.
index.html
<div ng-app="myApp" ng-controller="sourceController" >
<select class = "mdb-select md-form " aria-labelledby="dropdownMenuButton" id="sourcesByName">
<option class ="dropdown-item" ng-repeat="source in showsource">{{source}} </option>
</select>
</div>
index.js
var Report = angular.module('Report', []);
Report.controller('mainController', function($scope, $http) {
$scope.showdata = {}
// I want data here
// Get home page
$http.get('/api/v1/table')
.success(function(data) {
$scope.showdata = data;
console.log(data);
})
.error(function(error) {
console.log('Error: ' + error);
});
});
// Get all sources
Report.controller('sourceController', function($scope, $http) {
$scope.showsource =[];
$http.get('/api/v1/sources')
.success(function(data) {
var l = data.length;
data1=['Sources'];
var i;
for(i=0;i<l;i++){
data1.push(data[i]["source"]);
}
$scope.showsource = data1;
})
.error(function(error) {
console.log('Error: ' + error);
});
});
there is an table in my html page which I want to populate according to the dropdown value.
Thanks in Advance
get.success(...)-code and then reference the property with{{ selectedValue }}. Angular should pick up the change and re-render the new data. Or is that what you createdshowdatafor?