根据文档和其他SO问题,我应该可以输出一组键值/值对ng-repeat
$scope.getFilters = function(){
return {
film : true,
game : true,
music : true,
sport : true,
tv : true
}
}
$scope.filters = $scope.getFilters();
然后这是我的HTML
{{filters}}
<div
ng-repeat="(name,set) in filters"
>
{{name}} : {{set}}
</div>
但这就是我从中得到的:
{"film":true,"game":true,"music":true,"sport":true,"tv":true}
<!-- ngRepeat: (name,set) in filters -->
我尝试过JS小提琴,它有效。这只是我的代码片段,页面上有更多内容,但我无法将其全部粘贴在此处。
更新:刚发现此错误:
Error: Duplicates in a repeater are not allowed. Repeater: (name,set) in filters key: boolean:true
答案 0 :(得分:1)
这应该有效:
<div ng-repeat="row in [1,1,1] track by $index">
查看此问题以获取更多详情...... Angular ng-repeat Error "Duplicates in a repeater are not allowed."
希望这有帮助!