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

Method removeAt

packages/forms/src/model/form_array.ts:234–243  ·  view source on GitHub ↗

* Remove the control at the given `index` in the array. * * @param index Index in the array to remove the control. If `index` is negative, wraps around * from the back. If `index` is greatly negative (less than `-length`), removes the first * element. This behavior is the same a

(index: number, options: {emitEvent?: boolean} = {})

Source from the content-addressed store, hash-verified

232 * NOTE: Removing the FormArray will not mark it dirty. If you want to mark if dirty, call `markAsDirty()`.
233 */
234 removeAt(index: number, options: {emitEvent?: boolean} = {}): void {
235 // Adjust the index, then clamp it at no less than 0 to prevent undesired underflows.
236 let adjustedIndex = this._adjustIndex(index);
237 if (adjustedIndex < 0) adjustedIndex = 0;
238
239 if (this.controls[adjustedIndex])
240 this.controls[adjustedIndex]._registerOnCollectionChange(() => {});
241 this.controls.splice(adjustedIndex, 1);
242 this.updateValueAndValidity({emitEvent: options.emitEvent});
243 }
244
245 /**
246 * Replace an existing control.

Calls 2

_adjustIndexMethod · 0.95

Tested by

no test coverage detected