i'm trying to return ajax call value put in $scope in angular js but getting nothing idon't what happing here can you please check my code which i write below are the code
function GetDataarray() {
var jqxhr = $.ajax({
type: 'GET',
url: '@Url.Content("~/Home/GetPesrons")',
data: '{}',
dataType: 'json',
success: function (data, textStatus, XMLHttpRequest) {
//alert(JSON.stringify(data));
return JSON.stringify(data);
}
});
}
var app = angular.module('Napp', []);
app.controller('GetAlphabetical', function ($scope) {
$scope.filt = 'All';
$scope.setFilter = function (letter) {
$scope.filt = letter;
};
$scope.names = ['All', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
$scope.startsWith = function (customer) {
var lowerStr = (customer.Name + "").toLowerCase();
var letter = $scope.filt;
if (letter === 'All') return true;
return lowerStr.indexOf(letter.toLowerCase()) === 0;
}
$scope.Customer = GetDataarray();
});
And Html is here :
<div data-ng-app="Napp" ng-controller="GetAlphabetical">
Search :
<input type="text" ng-model="txtsearch" />
<table>
<tr>
<td ng-repeat="letter in names"> <span ng-click="setFilter(letter)">{{letter}}</span>|</td>
</tr>
</table>
<br />
<ul>
<li ng-repeat="cust in Customer | filter:startsWith | orderBy: 'Name' | filter : txtsearch">{{cust.Name}}</li>
</ul>