MCPcopy
hub / github.com/angular/angular / FormGroup

Class FormGroup

packages/forms/src/model/form_group.ts:189–672  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187 * @publicApi
188 */
189export class FormGroup<
190 TControl extends {[K in keyof TControl]: AbstractControl<any>} = any,
191> extends AbstractControl<
192 ɵTypedOrUntyped<TControl, ɵFormGroupValue<TControl>, any>,
193 ɵTypedOrUntyped<TControl, ɵFormGroupRawValue<TControl>, any>,
194 ɵTypedOrUntyped<TControl, ɵFormGroupArgumentValue<TControl>, any>
195> {
196 /**
197 * Creates a new `FormGroup` instance.
198 *
199 * @param controls A collection of child controls. The key for each child is the name
200 * under which it is registered.
201 *
202 * @param validatorOrOpts A synchronous validator function, or an array of
203 * such functions, or an `AbstractControlOptions` object that contains validation functions
204 * and a validation trigger.
205 *
206 * @param asyncValidator A single async validator or array of async validator functions
207 *
208 */
209 constructor(
210 controls: TControl,
211 validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null,
212 asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null,
213 ) {
214 super(pickValidators(validatorOrOpts), pickAsyncValidators(asyncValidator, validatorOrOpts));
215 (typeof ngDevMode === 'undefined' || ngDevMode) && validateFormGroupControls(controls);
216 this.controls = controls;
217 this._initObservables();
218 this._setUpdateStrategy(validatorOrOpts);
219 this._setUpControls();
220 this.updateValueAndValidity({
221 onlySelf: true,
222 // If `asyncValidator` is present, it will trigger control status change from `PENDING` to
223 // `VALID` or `INVALID`. The status should be broadcasted via the `statusChanges` observable,
224 // so we set `emitEvent` to `true` to allow that during the control creation process.
225 emitEvent: !!this.asyncValidator,
226 });
227 }
228
229 public controls: ɵTypedOrUntyped<TControl, TControl, {[key: string]: AbstractControl<any>}>;
230
231 /**
232 * Registers a control with the group's list of controls. In a strongly-typed group, the control
233 * must be in the group's type (possibly as an optional key).
234 *
235 * This method does not update the value or validity of the control.
236 * Use {@link FormGroup#addControl addControl} instead.
237 *
238 * @param name The control name to register in the collection
239 * @param control Provides the control for the given name
240 */
241 registerControl<K extends string & keyof TControl>(name: K, control: TControl[K]): TControl[K];
242 registerControl(
243 this: FormGroup<{[key: string]: AbstractControl<any>}>,
244 name: string,
245 control: AbstractControl<any>,
246 ): AbstractControl<any>;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…