0

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?

1 Answer 1

3

I suspect this should work for you

[(ngModel)]="searchText" (ngModelChange)="SearchTextChange()"
Sign up to request clarification or add additional context in comments.

2 Comments

what is the difference between ngModelChange and change? just curious. is it because ngModelChange based on backend model change?
change is HtmlElement event while ngModelChange is @Output EventEmitter that is firing on input and blur event

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.