为什么在实现ControlValueAccessor的writeValue方法时使用promise?

时间:2017-06-21 11:23:39

标签: angular es6-promise angular-material2

我参考了角度素材2的自动完成源代码,可以找到here

MdAutocompleteTrigger实施ControlValueAccessor。以下是writeValue方法的实现:

/**
   * Sets the autocomplete's value. Part of the ControlValueAccessor interface
   * required to integrate with Angular's core forms API.
   *
   * @param value New value to be written to the model.
   */
  writeValue(value: any): void {
    Promise.resolve(null).then(() => this._setTriggerValue(value));
  }

有人可以解释一下在这里使用Promise的必要性吗?

0 个答案:

没有答案