I have this code which allows the user to filter by a certain field:
<input type="text" class = "form-control" [(ngModel)]="siteFilter.site_name">
<button type="button" class="btn btn-default">Address</button>
<button type="button" class="btn btn-default">Site</button>
<button type="button" class="btn btn-default">Phone</button>
In the component.ts file:
siteFilter: any = { site_name: '', address:'', phone:'' };
I have 3 buttons that should depending on which one is clicked, change the ngModel.xxx
so that it will filter by that respective field.
I tried using an array that held the respective fields, and the button clicks would select the index, but then it was just printing out the string value instead of binding it to that model.