Interface ValueControl<T>

interface ValueControl<T = any> {
    registerOnChange(fn: (value?: null | T) => void): void;
    setDisabledState(isDisabled: boolean): void;
    writeValue(opt: { mode: "reset"; value?: undefined }): void;
    writeValue(
        opt: { mode?: "autocomplete" | "restore"; value: null | T },
    ): void;
    writeValue(opt: { mode?: WriteValueMode; value?: null | T }): void;
    writeValue(opt: WriteValueOptions<T>): void;
}

Type Parameters

  • T = any

Methods

  • This method is called when new ValueControl assigned to the form associated element.

    When implementing the registerOnChange method in your own value accessor, save the given function so your class calls it at the appropriate time.

    registerOnChange(fn: (_: any) => void): void {
    this._onChange = fn;
    }

    When the value changes in the UI, call the registered function to allow the forms API to update itself:


    onChange(event: Event){

    }

    Parameters

    • fn: (value?: null | T) => void

      the function to be called when a control want to change the value of a form associated element.

    Returns void