在Angular中正确实现触摸回调

时间:2017-06-19 11:23:13

标签: angular

我想知道在实现NG_VALUE_ACCESSOR的自定义控件中触摸回调的正确实现是什么。

registerOnTouched(touched: () => {}) {
  this.touched = touched;
}

我特别想知道,无论是点击下拉菜单,还是点击外部而不选择任何值,都应该拨打this.touched()。触摸回调是接受信件还是仅反映控件的价值变化?

1 个答案:

答案 0 :(得分:0)

/**
  * A control is marked `touched` once the user has triggered
  * a `blur` event on it.
  */
  get touched(): boolean { return this._touched; }

source