我有一个函数可以获取如下数据
function Model(){
self.DataArray=[];
self.GetDepartmentData = function () {
var params = { shiftsBackward: self.ShiftsBackwardToDisplay, shiftsForward: 1, departmentId:department};
console.log(params);
Ajax.Get({
url: DATA,
params: params,
success: function (data) {
self.DataArray = data[0];
}
});
}
}
它获取我需要的输出如下
Object {data: Array[1]}
data: Array[1]
0: Object
department: "1"
ShiftName: "Day"
Total: 61
当我试图将它绑定到default.aspx页面时,它没有显示任何东西。我确实将控制器链接到页面
<div ng-controller="controllerData">
<div ng-model="model.DataArray">
{{model.department}}
{{model.total}}
</div>
答案 0 :(得分:4)
为了获得数组,你应该使用ng-repeat
<div ng-repeat="dataarr in DataArray">
<span> {{dataarr.department}} </span>
<span> {{dataarr.total}} </span>
</div>