MCPcopy Index your code
hub / github.com/angular/angular / setUpModelChangePipeline

Function setUpModelChangePipeline

packages/forms/src/directives/shared.ts:291–306  ·  view source on GitHub ↗
(control: FormControl, dir: NgControl)

Source from the content-addressed store, hash-verified

289}
290
291function setUpModelChangePipeline(control: FormControl, dir: NgControl): void {
292 const onChange = (newValue?: any, emitModelEvent?: boolean) => {
293 // control -> view
294 dir.valueAccessor!.writeValue(newValue);
295
296 // control -> ngModel
297 if (emitModelEvent) dir.viewToModelUpdate(newValue);
298 };
299 control.registerOnChange(onChange);
300
301 // Register a callback function to cleanup onChange handler
302 // from a control instance when a directive is destroyed.
303 dir._registerOnDestroy(() => {
304 control._unregisterOnChange(onChange);
305 });
306}
307
308/**
309 * Links a FormGroup or FormArray instance and corresponding Form directive by setting up validators

Callers 1

Calls 2

registerOnChangeMethod · 0.65
_unregisterOnChangeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…