这是我的控制器:
'use strict';
/* Controllers */
function roles($scope, $http) {
delete $http.defaults.headers.common['X-Requested-With']
$http.get('/engine/ListRoles').success(function(data) {
$scope.roles = data;
});
$scope.orderProp = 'id';
}
这是我得到的 JSON 响应/engine/ListRoles/
data: "[{"External":false,"Filter":"","ID":25,"Name":"content editor","Permissions":[{"Description":"test","Group":"report","ID":2,"Name":"view"},{"Description":"test","Group":"report","ID":4,"Name":"delete"},{"Description":"test","Group":"report","ID":3,"Name":"edit"},{"Description":"test","Group":"report","ID":5,"Name":"customize"},{"Description":"test","Group":"manage","ID":1,"Name":"access"}]},{"External":false,"Filter":"","ID":26,"Name":"data editor","Permissions":[{"Description":"test","Group":"manage","ID":1,"Name":"access"},{"Description":"test","Group":"manage","ID":6,"Name":"cache"},{"Description":"test","Group":"report","ID":5,"Name":"customize"},{"Description":"test","Group":"report","ID":4,"Name":"delete"},{"Description":"test","Group":"report","ID":3,"Name":"edit"},{"Description":"test","Group":"report","ID":2,"Name":"view"}]},{"External":false,"Filter":"","ID":27,"Name":"guest","Permissions":[]},{"External":false,"Filter":"","ID":2,"Name":"super user","Permissions":[{"Description":"test","Group":"manage","ID":1,"Name":"access"},{"Description":"test","Group":"report","ID":2,"Name":"view"},{"Description":"test","Group":"report","ID":3,"Name":"edit"},{"Description":"test","Group":"report","ID":4,"Name":"delete"},{"Description":"test","Group":"manage","ID":6,"Name":"cache"},{"Description":"test","Group":"report","ID":5,"Name":"customize"}]},{"External":false,"Filter":"","ID":1,"Name":"user","Permissions":[{"Description":"test","Group":"report","ID":2,"Name":"view"},{"Description":"test","Group":"report","ID":5,"Name":"customize"}]}]"
resultcode: "200"
resulttext: ""
timestamp: "/Date(1369497355200+0300)/"
但是,当我尝试使用这个 ng-repeat 时:
<div id="table" ng-controller="roles">
<div>
<div ng-repeat="role in roles.data">
{{role.Name}}<br />
</div>
</div>
</div>
我只是得到一个巨大的空白 DIV 列表。