I have a table's headers which has to be populated based on the json {id, name} this.id is the ngModel name I have used in the component which need to be mapped for custom filter respectively.
say,
list=[{id:ageSearch,name:age},{id:adressSearch,name:adress}]
so when I enter the value for the first input text field,ageSearch is to be populated and it has to filter the data,similarly for adressSearch now I would like to know how to map the variable ageSearch,adressSearch dynamically inside a ngfor.
I tried using
<div *ngFor="let item of list;let index = index;trackBy:trackByIndex;">
<input [(ngModel)]="item[id]" placeholder="item">
</div>
But , its populating the value ageSearch instead of binding the variable . Can anyone please say whether I am trying something which is feasible or not. If so how can I achieve the expected flow.
The expected result should be
<div>
<input [(ngModel)]="ageSearch" placeholder="item">
</div>
<div>
<input [(ngModel)]="adressSearch" placeholder="item">
</div>
Edit: in component I have variables declared as let ageSearch:any; let adressSearch:any;
these values are to be passed to the custom filter. so I ahve to set the ngModel of the inputs to bind these variable names so that initially they appear blank on load and when we enter values they reflect the value of ageSearch and adressSearch resp. which is then passed to the custom filter. Thank You.