My goal is to filter an array of 'forms' by their 'id' and then return its corresponding 'fields'.
Here's what I currently have, but unfortunately nothing seems to be returned:
<select ng-options="option.displayName for option in forms.fields track by option.id|filter: {'id': component.form.id}" ng-model="component.field"></select>
The filtering on 'forms' works perfectly if I just want the complete form object,
forms|filter: {'id': component.form.id}
.
However, my specific requirement is to extract the field names and use them to populate the select dropdown.
{
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
}
]
}
]
}