From 0f81ef405bc08b4172e24979cf7f81b2c55f64fb Mon Sep 17 00:00:00 2001 From: SkyZeroZx <73321943+SkyZeroZx@users.noreply.github.com> Date: Fri, 17 Oct 2025 10:59:19 -0500 Subject: [PATCH] docs: Update FormArray.push usage (#64499) PR Close #64499 --- adev/src/content/guide/forms/reactive-forms.md | 2 +- adev/src/content/guide/forms/typed-forms.md | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/adev/src/content/guide/forms/reactive-forms.md b/adev/src/content/guide/forms/reactive-forms.md index 8c091c0174c..3aecc6a2baf 100644 --- a/adev/src/content/guide/forms/reactive-forms.md +++ b/adev/src/content/guide/forms/reactive-forms.md @@ -359,7 +359,7 @@ Use the getter syntax to create an `aliases` class property to retrieve the alia -Because the returned control is of the type `AbstractControl`, you need to provide an explicit type to access the method syntax for the form array instance. Define a method to dynamically insert an alias control into the alias's form array. The `FormArray.push()` method inserts the control as a new item in the array. +Because the returned control is of the type `AbstractControl`, you need to provide an explicit type to access the method syntax for the form array instance. Define a method to dynamically insert an alias control into the alias's form array. The `FormArray.push()` method inserts the control as a new item in the array, and you can also pass an array of controls to FormArray.push() to register multiple controls at once. diff --git a/adev/src/content/guide/forms/typed-forms.md b/adev/src/content/guide/forms/typed-forms.md index 6b6b5ed9b7e..dd969fac87b 100644 --- a/adev/src/content/guide/forms/typed-forms.md +++ b/adev/src/content/guide/forms/typed-forms.md @@ -8,7 +8,7 @@ As background for this guide, you should already be familiar with [Angular React -With Angular reactive forms, you explicitly specify a *form model*. As a simple example, consider this basic user login form: +With Angular reactive forms, you explicitly specify a _form model_. As a simple example, consider this basic user login form: ```ts const login = new FormGroup({ @@ -29,7 +29,7 @@ With strictly typed reactive forms, the above code does not compile, because the In addition to the added safety, the types enable a variety of other improvements, such as better autocomplete in IDEs, and an explicit way to specify form structure. -These improvements currently apply only to *reactive* forms (not [*template-driven* forms](guide/forms/template-driven-forms)). +These improvements currently apply only to _reactive_ forms (not [_template-driven_ forms](guide/forms/template-driven-forms)). ## Untyped Forms @@ -56,7 +56,7 @@ This control will be automatically inferred to have the type `FormControl`. If you want to have multiple different element types inside the array, you must use `UntypedFormArray`, because TypeScript cannot infer which element type will occur at which position. @@ -124,11 +131,11 @@ As a consequence, the type of `login.value` is `Partial<{email: string, password More specifically, the type of `login.value.email` is `string|undefined`, and TypeScript will enforce that you handle the possibly `undefined` value (if you have `strictNullChecks` enabled). -If you want to access the value *including* disabled controls, and thus bypass possible `undefined` fields, you can use `login.getRawValue()`. +If you want to access the value _including_ disabled controls, and thus bypass possible `undefined` fields, you can use `login.getRawValue()`. ### Optional Controls and Dynamic Groups -Some forms have controls that may or may not be present, which can be added and removed at runtime. You can represent these controls using *optional fields*: +Some forms have controls that may or may not be present, which can be added and removed at runtime. You can represent these controls using _optional fields_: ```ts interface LoginForm {