nanobots
nanobots

Reputation: 457

change in input with angular 2 dynamic detection

I have a textbox which act as a search text box. I would like to update the search on text change. This is what I tried with:

<input id="searchTextField" [(ngModel)]="searchText" (change)="SearchTextChange()" />

and the typescript backend code

private SearchTextChange(): void
{
//dostuff
}

problem is this only gets triggered off when I click somewhere outside of textbox. It doesn't gets triggered off when on the change of text. Why is this so?

Upvotes: 0

Views: 669

Answers (1)

yurzui
yurzui

Reputation: 214007

I suspect this should work for you

[(ngModel)]="searchText" (ngModelChange)="SearchTextChange()"

Upvotes: 3

Related Questions