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

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

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -