MCPcopy Create free account
hub / github.com/angular/angular / updateControlFromCustom

Function updateControlFromCustom

packages/forms/src/directives/ng_control.ts:312–332  ·  view source on GitHub ↗
(control: AbstractControl)

Source from the content-addressed store, hash-verified

310 }
311
312 private updateControlFromCustom(control: AbstractControl): void {
313 // `_pendingValue` and `_pendingChange` are only declared on `FormControl` (same as in
314 // `listenToCustomControlModel`).
315 const value = (control as FormControl)._pendingValue;
316 // Clear the pending state before `setValue` so `valueChanges` and `events` subscribers don't
317 // observe a committed value that is still marked as pending.
318 (control as FormControl)._pendingChange = false;
319 this.clearPendingCustomValue();
320 // The custom control is the source of `value`, so it already holds it. Record that before
321 // `setValue` so a `valueChanges` subscriber that synchronously sets a different value is
322 // still propagated by `ngControlUpdate`.
323 if (this.customControlBindings) {
324 this.customControlBindings.value = value;
325 }
326 if (control._pendingDirty) {
327 control.markAsDirty();
328 }
329 control.setValue(value, {emitModelToViewChange: false});
330 // Read `control.value` rather than `value` in case a `valueChanges` subscriber changed it.
331 this.viewToModelUpdate(control.value);
332 }
333
334 private discardPendingCustomValue(control: AbstractControl): void {
335 if (!this.hasPendingCustomValue) {

Callers

nothing calls this directly

Calls 3

markAsDirtyMethod · 0.65
setValueMethod · 0.65
viewToModelUpdateMethod · 0.45

Tested by

no test coverage detected