I want to disable the checkbox option for select
<mdb-select [options]="optionsList" type="multi_checkbox" [(ngModel)]="selected" placeholder="Choose your option" label="Example label"></mdb-select>
public selected = [];
public optionsList = [
{ id: 1, label: 'Option 1', disabled: false },
{ id: 2, label: 'Option 2', disabled: false } ,
{ id: 3, label: 'Disabled option', disabled: false } ,
];
ngOnInit() {
setTimeout(() => {
this.updateDisabledState(); // nothing happens here
this.optionsList = [...this.optionsList] // array reference change, Angular will trigger change detection for options input
}, 3000);
}
updateDisabledState() {
this.optionsSelect.forEach(option => {
option.disabled = true;
})
}
Just by adding disabled: true in the array didn't work, hence tried this way but this too failed to disable the checkbox
Approach: Angular only checks if an array reference has changed. If you add new option or update parameter of existing option, the change detection won't be triggered.