Creates a form NgControl instance from a domain model and binds it to a form control element. The form NgControl instance tracks the value, user interaction, and validation status of the control and keeps the view synced with the model. If used within a parent form, the directive will also register itself with the form as a child control.
This directive can be used by itself or as part of a larger form. All you
need is the ngModel
selector to activate it. For a two-way binding, use
the [(ngModel)]
syntax to ensure the model updates in both directions.
Learn more about ngModel
in the Guide Forms
and Template Syntax pages.
Examples
This is equivalent to having separate bindings:
Try the live example.
- Inheritance
- Object
- AbstractControlDirective
- NgControl
- NgModel
- Implements
-
- OnChanges
- Annotations
- Directive(selector: "[ngModel]:not([ngControl]):not([ngFormControl])", providers: const [formControlBinding], inputs: const ["model: ngModel"], outputs: const ["update: ngModelChange"], exportAs: "ngForm")
Constructors
- NgModel(@ @ @ List _validators, @ @ @ List _asyncValidators, @ @ @ List<ControlValueAccessor> valueAccessors)
Properties
- asyncValidator → AsyncValidatorFn
-
read-only
- control → Control
-
read-only
- dirty → bool
-
read-only, inherited
- errors → Map<String, dynamic>
-
read-only, inherited
- hashCode → int
-
Get a hash code for this object.
read-only, inherited - model → dynamic
-
read / write
- name → String
-
read / write, inherited
- path → List<String>
-
read-only
- pristine → bool
-
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited - touched → bool
-
read-only, inherited
- untouched → bool
-
read-only, inherited
- update → dynamic
-
read / write
- valid → bool
-
read-only, inherited
- validator → ValidatorFn
-
read-only
- value → dynamic
-
read-only, inherited
- valueAccessor → ControlValueAccessor
-
read / write, inherited
- viewModel → dynamic
-
read / write
Operators
-
operator ==(
other) → bool -
The equality operator.
inherited
Methods
-
ngOnChanges(
Map<String, SimpleChange> changes) → void -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited -
toString(
) → String -
Returns a string representation of this object.
inherited -
viewToModelUpdate(
newValue) → void