我有一个对象,我尝试从最高到最低过滤数据并将其限制为 8。我收到此错误,我不知道如何解决。发生了什么事,我该如何解决?非常感谢。
https://jsfiddle.net/bg3mkwvL/
<div class="col-xs-3" ng-repeat='item in people | orderBy: "-score" | limitTo: 8'>
<p>
{{item.name}} {{item.score}}
</p>
</div>
$scope.people={
"juan": { "name": "juan", "score":0},
"pedro": { "name": "pedro", "score":0},
"goku": { "name": "goku", "score":0},
}
我需要使用这个语法:
"juan": {"name": "juan", "score": 0}
然后我需要写例如'
console.log ($scope.people['juan'])
而且我需要在不循环的情况下获取对象。
最佳答案
您可以修改您的 json 对象数组,如下所示;
$scope.people= [
{ "name": "juan", "score":0},
{ "name": "pedro", "score":0},
{ "name": "goku", "score":0},
]
关于javascript - 使用降序过滤器生成 ng-repeat 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45899939/