angularjs - how update model value when input value is changed in Angularjs2 -
i want change model value input tag don't know how in best way.
here code have done that.
<div *ngfor='let l of list'> <input #temp [value]='l.test' (blur)='l.test=temp.value'/> <span (click)='check(l,temp.value)'></span> <div>
angular code
check(l,temp:string) { console.log(l.test); console.log(temp); }
i want without blur event. please suggest me better way this.
use can [(ngmodel)]
on field, provide 2 way binding on field, type in change l.test
value of particular element array.
markup
<div *ngfor='let l of list'> <input [(ngmodel)]='l.test'/> <div>
since angular 2 rc-5
, make ngmodel
2 way binding working have import formsmodule
in @ngmodule
import { formsmodule } '@angular/forms'; ///..other imports @ngmodule({ imports: [ browsermodule, formsmodule ], //< added formsmodule here declarations: [ appcomponent ], bootstrap: [ appcomponent ] })
you refer this answer know how use 2 way binding in angular 2.
Comments
Post a Comment