javascript - How to use onBlur event on Angular2? -
how detect onblur event in angular2? want use with
<input type="text">
can me understand how use it?
use (eventname)
while binding event dom, ()
used event binding. use ngmodel
2 way binding mymodel
variable.
markup
<input type="text" [(ngmodel)]="mymodel" (blur)="onblurmethod()">
code
export class appcomponent { mymodel: any; constructor(){ this.mymodel = '123'; } onblurmethod(){ alert(this.mymodel) } }
alternative(not preferable)
<input type="text" #input (blur)="onblurmethod($event.target.value)">
Comments
Post a Comment