ControlValueAccessor
Defined in: projects/view-angular-core/util/create-view-control-link.ts:4
Methods
Section titled “Methods”registerOnChange()
Section titled “registerOnChange()”registerOnChange(
fn):void
Defined in: projects/view-angular-core/util/create-view-control-link.ts:59
Parameters
Section titled “Parameters”any
The callback function to register
Returns
Section titled “Returns”void
Description
Section titled “Description”Registers a callback function that is called when the control’s value changes in the UI.
This method is called by the forms API on initialization to update the form model when values propagate from the view to the model.
When implementing the registerOnChange method in your own value accessor,
save the given function so your class calls it at the appropriate time.
Usage Notes
Section titled “Usage Notes”Store the change function
Section titled “Store the change function”The following example stores the provided function as an internal method.
When the value changes in the UI, call the registered function to allow the forms API to update itself:
registerOnTouched()
Section titled “registerOnTouched()”registerOnTouched(
fn):void
Defined in: projects/view-angular-core/util/create-view-control-link.ts:91
Parameters
Section titled “Parameters”any
The callback function to register
Returns
Section titled “Returns”void
Description
Section titled “Description”Registers a callback function that is called by the forms API on initialization to update the form model on blur.
When implementing registerOnTouched in your own value accessor, save the given
function so your class calls it when the control should be considered
blurred or “touched”.
Usage Notes
Section titled “Usage Notes”Store the callback function
Section titled “Store the callback function”The following example stores the provided function as an internal method.
On blur (or equivalent), your class should call the registered function to allow the forms API to update itself:
setDisabledState()?
Section titled “setDisabledState()?”
optionalsetDisabledState(isDisabled):void
Defined in: projects/view-angular-core/util/create-view-control-link.ts:109
Parameters
Section titled “Parameters”isDisabled
Section titled “isDisabled”boolean
The disabled status to set on the element
Returns
Section titled “Returns”void
Description
Section titled “Description”Function that is called by the forms API when the control status changes to or from ‘DISABLED’. Depending on the status, it enables or disables the appropriate DOM element.
Usage Notes
Section titled “Usage Notes”The following is an example of writing the disabled property to a native DOM element:
writeValue()
Section titled “writeValue()”writeValue(
obj):void
Defined in: projects/view-angular-core/util/create-view-control-link.ts:25
Parameters
Section titled “Parameters”any
The new value for the element
Returns
Section titled “Returns”void
Description
Section titled “Description”Writes a new value to the element.
This method is called by the forms API to write to the view when programmatic changes from model to view are requested.
Usage Notes
Section titled “Usage Notes”Write a value to the element
Section titled “Write a value to the element”The following example writes a value to the native DOM element.