export class Control
export class Control
exported from angular2/common defined in angular2/src/common/forms/model.ts (line 239)
Defines a part of a form that cannot be divided into other controls. Controls have values and
validation state, which is determined by an optional validation function.
Control is one of the three fundamental building blocks used to define forms in Angular, along
with ControlGroup and ControlArray.
Usage
By default, a Control is created for every <input> or other form component.
With NgFormControl or NgFormModel an existing Control can be
bound to a DOM element instead. This Control can be configured with a custom
validation function.
Example (live demo)
Constructor
constructor(value?: any, validator?: Function, asyncValidator?: Function)
constructor(value?: any, validator?: Function, asyncValidator?: Function)Not Yet Documented
Members
updateValue(value: any, {onlySelf, emitEvent, emitModelToViewChange}?: {
onlySelf?: boolean,
emitEvent?: boolean,
emitModelToViewChange?: boolean
}) : void
updateValue(value: any, {onlySelf, emitEvent, emitModelToViewChange}?: {
onlySelf?: boolean,
emitEvent?: boolean,
emitModelToViewChange?: boolean
}) : void
Set the value of the control to value.
If onlySelf is true, this change will only affect the validation of this Control
and not its parent component. If emitEvent is true, this change will cause a
valueChanges event on the Control to be emitted. Both of these options default to
false.
If emitModelToViewChange is true, the view will be notified about the new value
via an onChange event. This is the default behavior if emitModelToViewChange is not
specified.
registerOnChange(fn: Function) : void
registerOnChange(fn: Function) : void
Register a listener for change events.