I'm trying to figure out how to implement the setDisabledState function that is a part of the ControlValueAccessor interface, but I can't figure out how to actually trigger the function from outside of the component itself.
Within the component I have
control = new FormControl();
setDisabledState(isDisabled: boolean): void {
this._renderer.setProperty(this.formField.nativeElement, 'disabled', isDisabled);
}
This sets my disabled styling fine if I do the below inside the NgOnInit of my component. But I want to be able to control the disabled state of my component through property binding.
this.tenantListFormControl.disable();
However, nothing actually triggers the function.
I've tried
<app-custom-control [attr.disabled]="true"></app-custom-control>
<app-custom-control disabled></app-custom-control>
<app-custom-control [disabled]="true"></app-custom-control>
The last one isn't even valid as "Property disabled is not provided by any applicable directives etc..." as I don't have @Input() disabled anywhere on the component. Which wouldn't help anyway because what am I supposed to do with that once I've set it, I can't subscribe to it and trigger the setDisabledState function that way as it's not an observable.
How do I actually trigger this function and disable my component?