<body ng-app="myApp">
<div ng-controller="customersCtrl">
<table>
<tr ng-repeat="res in customers">
<td>{{ $index + 1 }}</td>
<td>{{ res.Name }}</td>
<td>{{ res.City }}</td>
</tr>
</table>
</div>
</body>
var myApp = angular.module('myApp', []);
myApp.controller("customersCtrl", function ($scope,$http) {
$http.post('Default.aspx/Getdata', { data: {} })
.success(function (response) {
$scope.customers = response.d;
})
.error(function (data, status, headers, config) {
alert(status+"-------"+data);
});
});
server side function:
[WebMethod]
public static string Getdata()
{
List<customors> people = new List<customors>{
new customors{Name = "biss",City="Lebanon"},
new customors{Name = "jiji",City="America"}
};
JavaScriptSerializer serialiser = new JavaScriptSerializer();
string json = serialiser.Serialize(people);
return json; // [{"Name":"biss","City":"Lebanon"},{"Name":"jiji","City":"America"}]
}
public class customors
{
public string Name{get;set;}
public string City{get;set;}
}
but No result is being displayed . what i am doing wrong ?