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