<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script>
<script>
angular.module("myapp", []).controller("MyController", function ($scope, $http) {
//$scope.retData = {};
//$scope.retData.getResult = function (item, event) {
$http.post('Sample.aspx/GetEmployees', { data: {} })
.success(function (data, status, headers, config) {
debugger
$scope.retData = data.d;
var nik = data.d;
})
.error(function (data, status, headers, config) {
$scope.status = status;
});
//}
}).config(function ($httpProvider) {
$httpProvider.defaults.headers.post = {};
$httpProvider.defaults.headers.post["Content-Type"] =
"application/json; charset=utf-8";
});
</script>
<body ng-app="myapp">
<div ng-controller="MyController">
<p>Looping with objects:</p>
<ul>
<li ng-repeat="x in retData">
{{ x.Education + ', ' + x.UserName }}
</li>
</ul>
</div>
</body>
[{
"UserId": 1,
"UserName": "Suresh",
"Education": "B.Tech",
"Location": "Chennai",
"Item": 1,
"Quantity": 2
}, {
"UserId": 2,
"UserName": "Rohini",
"Education": "M.Sc. ",
"Location": "Chennai",
"Item": 5,
"Quantity": 8
}, {
"UserId": 3,
"UserName": "Praveen ",
"Education": "B.Tech",
"Location": "Guntur",
"Item": 12,
"Quantity": 7
}, {
"UserId": 4,
"UserName": "Lal",
"Education": "M.Sc. ",
"Location": "Agra",
"Item": 44,
"Quantity": 7
}, {
"UserId": 5,
"UserName": "Puneet",
"Education": "B.Sc.",
"Location": "Gurgaon",
"Item": 9,
"Quantity": 9
}, {
"UserId": 6,
"UserName": "Rohit",
"Education": "BCA",
"Location": "Delhi",
"Item": 76,
"Quantity": 90
}]
及以上是动态从.CS文件中获取Json数据。
数据在li字段中没有动态绑定。
所以请任何人帮我解决我做错了什么。 非常感谢。