![](/img/trans.png)
[英]Is there a way to show a property of a filtered array in angularjs filter?
[英]AngularJS: To filter array and access nested array inside filtered result
我想通過其“ id”過濾一組“形式”,然后返回其“字段”。
目前我有這個-但是什么也沒返回:
<select ng-options="option.displayName for option in forms.fields track by option.id|filter: {'id': component.form.id}" ng-model="component.field"></select>
如果我只想要完整的表單對象, forms|filter: {'id': component.form.id}
,則對'forms'進行過濾的效果很好。 但是,我想獲取字段名稱並使用這些字段填充此選擇。
{
forms: [
{
id: 1,
name: 'form 1',
fields: [
{
displayName: 'name 1',
id: 1
},
{
displayName: 'name 2',
id: 2
},
{
displayName: 'name 3',
id: 3
}
}
},
{
id: 1,
name: 'form 1'
fields: [
{
displayName: 'name 1',
id: 1
},
{
displayName: 'name 2',
id: 2
},
{
displayName: 'name 3',
id: 3
}
]
}
]
}
我曾嘗試過此操作,但未放入[0],但這按我想要的方式工作。
option.displayName for option in (forms|filter: {'id': component.form.id})[0].fields track by option.id
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.