Not working when I use to populate data in dropdown change AngularJS.
<select name="ddllocation" id="ddllocation" class="ml73" ng-model="selectedItem.value" ng-change="GetCustomers(1)">
<option value="0" label="Select" ng-selected="selected">Select</option>
<option ng-repeat="dataloc in Locations" value="{{dataloc.Value}}">{{dataloc.Text}}
</option>
</select>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/angular-utils-pagination@0.11.1/dirPagination.js"></script>
<script type="text/javascript">
var app = angular.module('MyApp', ['angularUtils.directives.dirPagination']);
app.controller('MyController', function ($scope, $http) {
var post = $http({
method: "POST",
url: "StockLedgerwithAngular.aspx/GetLocations",
dataType: 'json',
data: {},
headers: { "Content-Type": "application/json" }
});
post.success(function (response) {
$scope.Locations = response.d;
});
$scope.Customers = [];
$scope.PageIndex = 1;
$scope.RecordCount = 0;
$scope.PageSize = 20;
$scope.SearchTerm = "";
$scope.example = {
value: new Date()
};
$scope.selectedItem = {
value: "Select Store"
};
$scope.GetCustomers = function (index) {
$scope.Customers = [];
$http.post("StockLedgerwithAngular.aspx/GetCustomers",
{ PageNo: index, PageSize: $scope.PageSize, searchTerm: $scope.SearchTerm, selectedItem: $scope.selectedItem, searchcat: $scope.searchcat, to_date: Date.parse($scope.to_date), from_date: Date.parse($scope.from_date) },
{ headers: { 'Content-Type': 'application/json'} })
.success(function (response) {
$scope.Customers = response.d.Customers;
$scope.RecordCount = response.d.TotalRecords;
});
}
$scope.GetCustomers($scope.PageIndex);
});
</script>
<System.Web.Services.WebMethod()>
Public Shared Function GetLocations() As List(Of Object)
' Bind list from Database.
Dim dataloc As List(Of Object) = New List(Of Object)()
Dim con As New SqlConnection(connection)
Dim cmd As New SqlCommand("", con)
con.Open()
cmd.CommandType = CommandType.Text
cmd.CommandText = "select Title,SLocationID from StockLocation "
Dim rdr As SqlDataReader = cmd.ExecuteReader
While rdr.Read()
dataloc.Add(New With {.Value = rdr("SLocationID").ToString(), .Text = rdr("Title").ToString()})
End While
rdr.Close()
con.Close()
Return dataloc
End Function