2
我希望有人能幫助我。 對於角1.3我目前的項目中,我使用這個列表:角度1.3過濾數組對象的列表屬性
$scope.myList = [{
id: "obj1",
content: [{
id: 1,
name: 'attr 1'
}, {
id: 2,
name: 'attr 2'
}, {
id: 3,
name: 'attr 3'
}]
}, {
id: "obj2",
content: [{
id: 4,
name: 'attr 4'
}, {
id: 5,
name: 'attr 5'
}, {
id: 6,
name: 'attr 6'
}]
}, {
id: "obj3",
content: [{
id: 7,
name: 'attr 7'
}, {
id: 8,
name: 'attr 8'
}, {
id: 9,
name: 'attr 9'
}]
}];
我想獲得它具有內容數組中的ID X的對象。
我用這個NG-重複:
<ul>
<li ng-repeat="item in myList | filter: {content: [{id:1}]}">
{{item}}
</li>
</ul>
當我使用ID:1,ID:4或ID:7它的工作原理,但不是爲其他ID ...
有沒有人有任何想法嗎?
編輯
我終於找到了問題的根源,我採用了棱角分明1.3.0。升級到1.3.11後,它工作了!
我試過你的建議,但它不工作,因爲'內容'包含一個對象數組。如果對象的「內容」有一個屬性「ID」,那麼你完全正確... – user2246413 2015-01-27 20:46:23
@ user2246413,適合你(稍作修改用於說明)的數據:http://plnkr.co/edit/katQANxYUVmWvu8yeltU?p =預覽 – 2015-01-27 20:56:02
@ user2246413,你有沒有嘗試過我如何在重擊中展示? – 2015-02-01 23:17:15