* Patches the value of the `FormArray`. It accepts an array that matches the * structure of the control, and does its best to match the values to the correct * controls in the group. * * It accepts both super-sets and sub-sets of the array without throwing an error. * * @usageNotes
(
value: ɵFormArrayValue<TControl>,
options: {
onlySelf?: boolean;
emitEvent?: boolean;
} = {},
)
| 365 | * the {@link AbstractControl#updateValueAndValidity updateValueAndValidity} method. |
| 366 | */ |
| 367 | override patchValue( |
| 368 | value: ɵFormArrayValue<TControl>, |
| 369 | options: { |
| 370 | onlySelf?: boolean; |
| 371 | emitEvent?: boolean; |
| 372 | } = {}, |
| 373 | ): void { |
| 374 | // Even though the `value` argument type doesn't allow `null` and `undefined` values, the |
| 375 | // `patchValue` can be called recursively and inner data structures might have these values, |
| 376 | // so we just ignore such cases when a field containing FormArray instance receives `null` or |
| 377 | // `undefined` as a value. |
| 378 | if (value == null /* both `null` and `undefined` */) return; |
| 379 | |
| 380 | value.forEach((newValue, index) => { |
| 381 | if (this.at(index)) { |
| 382 | this.at(index).patchValue(newValue, {onlySelf: true, emitEvent: options.emitEvent}); |
| 383 | } |
| 384 | }); |
| 385 | this.updateValueAndValidity(options); |
| 386 | } |
| 387 | |
| 388 | /** |
| 389 | * Resets the `FormArray` and all descendants are marked `pristine` and `untouched`, and the |
nothing calls this directly
no test coverage detected