首页 > 解决方案 > when using [(ngModel)] directive, what is the event expression called to detect change?

问题描述

Using [(ngModel)]="value" directive inside an Input control which is rendered as a range slider. The two-way binding side of this works nicely, but I would like to be able to fire off some code when the value changes.

What expression/function name should I use with this form of ngModel binding? Documentation doesn't seem to indicate this unless I'm missing something.

标签: angularangular2-forms

解决方案


您可以收听值更改(ngModelChange)时调用的事件。ngModel

(ngModelChange)="takeAction()"

-

takeAction() {
   // called invoke when value of `ngModel` Changes
}

推荐阅读