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

Method setValue

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

* Sets the value of the `FormGroup`. It accepts an object that matches * the structure of the group, with control names as keys. * * @usageNotes * ### Set the complete value for the form group * * ```ts * const form = new FormGroup({ * first: new FormControl(), * last:

(
    value: ɵFormGroupRawValue<TControl>,
    options: {
      onlySelf?: boolean;
      emitEvent?: boolean;
    } = {},
  )

Source from the content-addressed store, hash-verified

427 * When false, no events are emitted.
428 */
429 override setValue(
430 value: ɵFormGroupRawValue<TControl>,
431 options: {
432 onlySelf?: boolean;
433 emitEvent?: boolean;
434 } = {},
435 ): void {
436 untracked(() => {
437 assertAllValuesPresent(this, true, value);
438 (Object.keys(value) as Array<keyof TControl>).forEach((name) => {
439 assertControlPresent(this, true, name as any);
440 (this.controls as any)[name].setValue((value as any)[name], {
441 onlySelf: true,
442 emitEvent: options.emitEvent,
443 });
444 });
445 this.updateValueAndValidity(options);
446 });
447 }
448
449 /**
450 * Patches the value of the `FormGroup`. It accepts an object with control

Callers

nothing calls this directly

Calls 7

untrackedFunction · 0.90
assertAllValuesPresentFunction · 0.90
assertControlPresentFunction · 0.90
keysMethod · 0.65
setValueMethod · 0.65
forEachMethod · 0.45

Tested by

no test coverage detected