【发布时间】:2015-11-10 17:27:21
【问题描述】:
我有一点问题。我正在尝试使用 ng-repeat 来显示一些数据:
ng-repeat="color in apples[{{index}}].color"
在哪里
$scope.index = $stateParams.index;
但是,我收到一个语法错误。
在这个例子中动态添加索引到数组的正确方法是什么?
【问题讨论】:
标签: arrays angularjs ng-repeat
我有一点问题。我正在尝试使用 ng-repeat 来显示一些数据:
ng-repeat="color in apples[{{index}}].color"
在哪里
$scope.index = $stateParams.index;
但是,我收到一个语法错误。
在这个例子中动态添加索引到数组的正确方法是什么?
【问题讨论】:
标签: arrays angularjs ng-repeat
只需使用循环索引:
ng-repeat="color in apples[$index].color"
或
ng-repeat="color in apples[index].color"
【讨论】: