嗨,我是 Angular 新手,只是想学习如何做一些事情。我一直在尝试显示以下数据。使用适用于 chrome 的 Batarang 插件,我可以看到我的宁静 Web 服务返回以下 json,该 json 被包装到我的模型中。
{
course: {
country: Test1
numberEnrolledPerMonthPerWeek: {
entry:
[ {
key: 2
value: {
numberEnrolled: 0
weeks: 2
year: 2011
}
} , {
key: 3
value: {
numberEnrolled: 4
weeks: 3
year: 2011
}
} , {
key: 4
value: {
numberEnrolled: 6
weeks: 4
year: 2011
}
} , {
key: 8
value: {
numberEnrolled: 0
weeks: 8
year: 2011
}
}
]
}
}
}
我正在尝试将每个键的 numberEnrolled 值取出到一列中。所以在我的html中,我有以下内容
<table class="table table-striped table-bordered">
<tr ng-repeat="course in enrolledcourses.enrolledEnrolment">
<td>
{{course.country}}
</td>
<td>
{{course.numberEnrolledPerMonthPerWeek[2].numberEnrolled}}
</td>
</tr>
</table>
{{course.numberEnrolledPerMonthPerWeek[2].numberEnrolled}} 没有返回任何值,所以任何人都可以告诉我获取 numberEnrolled 值的正确语法是什么。
我努力了
{{course.numberEnrolledPerMonthPerWeek.2.numberEnrolled}}
{{course.numberEnrolledPerMonthPerWeek[2][numberEnrolled]}}
我的控制器代码如下
.controller('PeopleCtrl', function($scope, recruitmentFactory) {
$scope.enrolledcourses = recruitmentFactory.get();
$scope.test = "hello";
$scope.save = function() {
alert("save has been called");
};
})