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)    } } 

demo

alternative(not preferable)

<input type="text" #input (blur)="onblurmethod($event.target.value)"> 

demo


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -