MCPcopy Create free account
hub / github.com/angular/angular / NgModel

Class NgModel

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

InputInterface · 0.90
OutputInterface · 0.90

Tested by

no test coverage detected