Reacting to Keyup Events with Angular

Photo by Nikhita Singhal on Unsplash

Updated Version

Scenario

Approach

keyup(event) {
console.log(event);
console.log(this.fieldvalue);
}

Note that we are logging the value both from the event that the handler receives and the fieldvalue that we bind in the component declaration.

Next declare the input field in the component template (Note that the event must start with $ as in $event ):

<input placeholder="Type stuff ..." [value]="fieldvalue" (keyup)="keyup($event.target.value)">

Brought to You By

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store