I want to setup a reusable dropdown menu whereby I pass an array of objecs to the @Input of my dropdown component and then update some labels in it.
The array fields will be different each time. One array might have a displayName string field, while another array will have a string called id as the field I want to reference, for example.
I'm not sure how to reference these on a per instance basis.
Dropdown HTML:
<ng-container *ngFor="let item of content">
<span class="button-label">{{item.whatever-the-field-is}}</span>
</ng-container>
Dropdown Component:
@Input() content: Array<any> = [];
Dropdown Instance:
<multi-button-dropdown [content]="(myArrayObservable$ | async)"></multi-button-dropdown>
Example Arrays:
users = [
{
id: 'afvnf102841-251',
username: 'Joe Bloggs'
}
...
]
members = [
{
displayName: 'Han Solo',
location: 'Space'
}
...
]
Question:
How do i setup the dropdown.html/component so that the <span> {{item....}} reference will be displayName for the members[] instance, id for the users[] instance and so on, passed in by another @Input value?