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

Class NgForm

packages/forms/src/directives/ng_form.ts:127–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125 standalone: false,
126})
127export class NgForm extends ControlContainer implements Form, AfterViewInit {
128 /**
129 * @description
130 * Returns whether the form submission has been triggered.
131 */
132 get submitted(): boolean {
133 return untracked(this.submittedReactive);
134 }
135 /** @internal */
136 readonly _submitted = computed(() => this.submittedReactive());
137 private readonly submittedReactive = signal(false);
138
139 private _directives = new Set<NgModel>();
140
141 /**
142 * @description
143 * The `FormGroup` instance created for this form.
144 */
145 form: FormGroup;
146
147 /**
148 * @description
149 * Event emitter for the "ngSubmit" event
150 */
151 ngSubmit = new EventEmitter();
152
153 /**
154 * @description
155 * Tracks options for the `NgForm` instance.
156 *
157 * **updateOn**: Sets the default `updateOn` value for all child `NgModels` below it
158 * unless explicitly set by a child `NgModel` using `ngModelOptions`). Defaults to 'change'.
159 * Possible values: `'change'` | `'blur'` | `'submit'`.
160 *
161 */
162 @Input('ngFormOptions') options!: {updateOn?: FormHooks};
163
164 constructor(
165 @Optional() @Self() @Inject(NG_VALIDATORS) validators: (Validator | ValidatorFn)[],
166 @Optional()
167 @Self()
168 @Inject(NG_ASYNC_VALIDATORS)
169 asyncValidators: (AsyncValidator | AsyncValidatorFn)[],
170 @Optional()
171 @Inject(CALL_SET_DISABLED_STATE)
172 private callSetDisabledState?: SetDisabledStateOption,
173 ) {
174 super();
175 this.form = new FormGroup(
176 {},
177 composeValidators(validators),
178 composeAsyncValidators(asyncValidators),
179 );
180 }
181
182 /** @docs-private */
183 ngAfterViewInit() {
184 this._setUpdateStrategy();

Callers

nothing calls this directly

Calls 3

computedFunction · 0.90
signalFunction · 0.90
InputInterface · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…