* Insert a new `AbstractControl` at the end of the array. * * @param control Form control to be inserted * @param options Specifies whether this FormArray instance should emit events after a new * control is added. * * `emitEvent`: When true or not supplied (the default), both the
(control: TControl | Array<TControl>, options: {emitEvent?: boolean} = {})
| 182 | * NOTE: Pushing to the FormArray will not mark it dirty. If you want to mark if dirty, call `markAsDirty()`. |
| 183 | */ |
| 184 | push(control: TControl | Array<TControl>, options: {emitEvent?: boolean} = {}): void { |
| 185 | if (Array.isArray(control)) { |
| 186 | control.forEach((ctrl) => { |
| 187 | this.controls.push(ctrl); |
| 188 | this._registerControl(ctrl); |
| 189 | }); |
| 190 | } else { |
| 191 | this.controls.push(control); |
| 192 | this._registerControl(control); |
| 193 | } |
| 194 | this.updateValueAndValidity({emitEvent: options.emitEvent}); |
| 195 | this._onCollectionChange(); |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * Insert a new `AbstractControl` at the given `index` in the array. |