using the ng change in angular 2 using ng model variable

前端 未结 2 1922
不思量自难忘°
不思量自难忘° 2021-02-03 18:05

How can I use the ng-change event in angular 2? Whenever the ng-model variable is changed, a function has to be called.

[(ngModel)]=\"variable\"
ngchange=variab         


        
2条回答
  •  礼貌的吻别
    2021-02-03 18:59

    component have two-way binding

    • () for output
    • [] for input

    that means you can use ==>[value]="variable"<== for showing data on html and ==>(input)="setVariable($event)"<== to update your var in ts/js.

    event.target.value

    FYI==>https://angular.io/docs/ts/latest/guide/user-input.html

提交回复
热议问题