Skip to content

Commit 2ecbc4e

Browse files
JeanMecheAndrewKushnir
authored andcommitted
docs: add a callout that adding/removing to formArray doesn't not mark dirty (angular#64337)
fixes angular#36788 PR Close angular#64337
1 parent dc37100 commit 2ecbc4e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/forms/src/model/form_array.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ export class FormArray<TControl extends AbstractControl<any> = any> extends Abst
174174
* * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
175175
* `valueChanges` observables emit events with the latest status and value when the control is
176176
* inserted. When false, no events are emitted.
177+
*
178+
* NOTE: Pushing to the FormArray will not mark it dirty. If you want to mark if dirty, call `markAsDirty()`.
177179
*/
178180
push(control: TControl | Array<TControl>, options: {emitEvent?: boolean} = {}): void {
179181
if (Array.isArray(control)) {
@@ -201,6 +203,8 @@ export class FormArray<TControl extends AbstractControl<any> = any> extends Abst
201203
* * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
202204
* `valueChanges` observables emit events with the latest status and value when the control is
203205
* inserted. When false, no events are emitted.
206+
*
207+
* NOTE: Inserting to the FormArray will not mark it dirty. If you want to mark if dirty, call `markAsDirty()`.
204208
*/
205209
insert(index: number, control: TControl, options: {emitEvent?: boolean} = {}): void {
206210
this.controls.splice(index, 0, control);
@@ -220,6 +224,8 @@ export class FormArray<TControl extends AbstractControl<any> = any> extends Abst
220224
* * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
221225
* `valueChanges` observables emit events with the latest status and value when the control is
222226
* removed. When false, no events are emitted.
227+
*
228+
* NOTE: Removing the FormArray will not mark it dirty. If you want to mark if dirty, call `markAsDirty()`.
223229
*/
224230
removeAt(index: number, options: {emitEvent?: boolean} = {}): void {
225231
// Adjust the index, then clamp it at no less than 0 to prevent undesired underflows.

0 commit comments

Comments
 (0)