我正在查看NgModel的源代码。我了解其中的大部分内容,除了它如何设置value输入的初始值。
NgModel extends NgControl
..
NgControl extends NgControlDirective
..
NgControlDirective有这个代码:
get value(): any { return this.control ? this.control.value : null; }
所以如果我们设置this.control.value它会自动设置为valueof input。好的。
但this.control.setValue仅在更新时完成NgModel。
它如何知道最初设置该值。
我猜它与
this.valueAccessor = selectValueAccessor(this, valueAccessors);
