NgControlGroup class
Creates and binds a control group to a DOM element.
This directive can only be used as a child of NgForm or NgFormModel.
Example:
@Component(
selector: 'my-app',
directives: const [formDirectives],
template: '''
<div>
<h2>Angular2 Control & AbstractControlGroup Example</h2>
<form #f="ngForm">
<div ngControlGroup="name" #cg-name="form">
<h3>Enter your name:</h3>
<p>First: <input ngControl="first" required></p>
<p>Middle: <input ngControl="middle"></p>
<p>Last: <input ngControl="last" required></p>
</div>
<h3>Name value:</h3>
<pre>{{valueOf(cgName)}}</pre>
<p>Name is {{cgName?.control?.valid ? "valid" : "invalid"}}</p>
<h3>What's your favorite food?</h3>
<p><input ngControl="food"></p>
<h3>Form value</h3>
<pre>{{valueOf(f)}}</pre>
</form>
</div>
'''
})
class App {
String valueOf(NgControlGroup cg) {
if (cg.control == null) {
return null;
}
return JSON.encode(cg.control.value, null, 2);
}
}
This example declares a control group for a user's name. The value and validation state of this group can be accessed separately from the overall form.
- Inheritance
- Annotations
-
- @Directive(selector: '[ngControlGroup]', providers: [ExistingProvider(ControlContainer, NgControlGroup)], exportAs: 'ngForm')
Constructors
-
NgControlGroup(@SkipSelf() ControlContainer<
AbstractControlGroup> _parent, @Optional() @Self() @Inject(NG_VALIDATORS) List? validators)
Properties
- control → AbstractControlGroup?
-
Get the AbstractControlGroup backing this binding.
no setteroverride
- dirty → bool?
-
no setterinherited
- disabled ↔ bool?
-
getter/setter pairinherited-getter
- enabled → bool?
-
no setterinherited
-
errors
→ Map<
String, dynamic> ? -
no setterinherited
- formDirective → Form
-
Get the Form to which this group belongs.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- name ↔ String?
-
getter/setter pairinherited-getteroverride-setter
-
path
→ List<
String?> -
Get the path to this control group.
no setteroverride
- pristine → bool?
-
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- touched → bool?
-
no setterinherited
- untouched → bool?
-
no setterinherited
- valid → bool?
-
no setterinherited
- validator → ValidatorFn?
-
final
- value → dynamic
-
no setterinherited
Methods
-
ngOnDestroy(
) → void - Executed before the directive is removed from the DOM and destroyed.
-
ngOnInit(
) → void - Executed after the first change detection run for a directive.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
{dynamic value}) → void -
Resets the form control.
inherited
-
toggleDisabled(
bool isDisabled) → void -
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited