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

Class NgModel

packages/forms/src/directives/ng_model.ts:170–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168 standalone: false,
169})
170export class NgModel extends NgControl implements OnChanges, OnDestroy {
171 public override readonly control: FormControl = new FormControl();
172
173 // At runtime we coerce arbitrary values assigned to the "disabled" input to a "boolean".
174 // This is not reflected in the type of the property because outside of templates, consumers
175 // should only deal with booleans. In templates, a string is allowed for convenience and to
176 // match the native "disabled attribute" semantics which can be observed on input elements.
177 // This static member tells the compiler that values of type "string" can also be assigned
178 // to the input in a template.
179 /** @docs-private */
180 static ngAcceptInputType_isDisabled: boolean | string;
181
182 /** @internal */
183 _registered = false;
184
185 /**
186 * Internal reference to the view model value.
187 * @docs-private
188 */
189 viewModel: any;
190
191 /**
192 * @description
193 * Tracks the name bound to the directive. If a parent form exists, it
194 * uses this name as a key to retrieve this control's value.
195 */
196 @Input() override name: string = '';
197
198 /**
199 * @description
200 * Tracks whether the control is disabled.
201 */
202 @Input('disabled') isDisabled!: boolean;
203
204 /**
205 * @description
206 * Tracks the value bound to this directive.
207 */
208 @Input('ngModel') model: any;
209
210 /**
211 * @description
212 * Tracks the configuration options for this `ngModel` instance.
213 *
214 * **name**: An alternative to setting the name attribute on the form control element. See
215 * the [example](api/forms/NgModel#using-ngmodel-on-a-standalone-control) for using `NgModel`
216 * as a standalone control.
217 *
218 * **standalone**: When set to true, the `ngModel` will not register itself with its parent form,
219 * and acts as if it's not in the form. Defaults to false. If no parent form exists, this option
220 * has no effect.
221 *
222 * **updateOn**: Defines the event upon which the form control value and validity update.
223 * Defaults to 'change'. Possible values: `'change'` | `'blur'` | `'submit'`.
224 *
225 */
226 @Input('ngModelOptions') options!: {name?: string; standalone?: boolean; updateOn?: FormHooks};
227

Callers

nothing calls this directly

Calls 2

InputInterface · 0.90
OutputInterface · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…