Reputation: 281
I have acustom pipe filter that allows me to search in my model the search text and i'm struggling to make it work on button press instead of user input. Right now i'm trying to do it like that:
<input [{ngModel}="SearchText" type="text">
and i create my data like this:
<tr *ngFor="let c for char | filter : SearchText">
<td> {{c.Name}} </td>
</tr>
So this works.
And now i try to add something like this:
<button type="button" ng-click="searchText = {Name: Ragnar}">Ragnar</button>
And this doesn't work. I also tried:
<button type="button" [{ngModel}="SearchText">Ragnar</button>
But it doesn't seem to read Ragnar too. Any ideas?
Angular 4.
Upvotes: 0
Views: 1255
Reputation: 222582
There are few mistakes
change
From
<input [{ngModel}="SearchText" type="text">
To
<input [(ngModel)]="SearchText" type="text">
and (click)
instead of ng-click
<button type="button" (click)="searchText = {Name: 'Ragnar'}">Ragnar</button>
Upvotes: 2