Reputation: 1827
I have the following custom input in my code:
<nivel-servico-slider formControlName="fornecedor_a"></nivel-servico-slider>
which has all properties for a custom input as described in Angular's guide to creating a custom input, however when I set that FormControl to disabled:
this.form.get('fornecedor_a').disable();
the disabled attribute is not set to the custom component (<nivel-servico-slider>
), which doesn't trigger the get/setter for disabled inside the component:
@Input()
get disabled(): boolean {
return this.internalDisabled;
}
set disabled(value: boolean) {
console.log(value);
this.internalDisabled = coerceBooleanProperty(value);
if (this.internalDisabled) {
this.input.disable();
} else {
this.input.enable();
};
this.stateChanges.next();
}
What am I doing wrong?
Upvotes: 0
Views: 1405
Reputation: 12036
if you are using formControlName on your custom component, there is most likely a custom value accessor implemented https://angular.io/api/forms/ControlValueAccessor
so, to catch "disabling", you should implement setDisabledState(isDisabled: boolean)?: void
Upvotes: 1