Angular 2 – Custom Form Control – Disable

Your component needs to implement the setDisabledState function which is defined in the ControlValueAccessor interface (see docs).

E.g. (assuming the renderer has been injected in the constructor):

setDisabledState(isDisabled: boolean) {
    this.renderer.setElementProperty(this.textInput.nativeElement, 'disabled', isDisabled);
    // disable other components here
}

Leave a Comment