I am currently working with Angular7 and I am looking for a way to conditionally make a select element readonly or disabled.
Regarding the readonly attribute, my attempt was:
editable: boolean = true;
Here is the template I used:
<select #listOfOptions="ngModel" [(ngModel)]="myList" [readonly]="!editable" class="form-control">
</select>
However, this resulted in the following error message:
Error: Template parse errors: Can't bind to 'readOnly' since it isn't a known property of 'select'.
An existing issue mentions this problem, but no solutions have been provided yet.
As for the disabled attribute, here's what I attempted:
<select [attr.disabled]="!editable">
...
</select>
Unfortunately, the select element always stays disabled regardless of how I adjust the editable variable.
Any assistance would be greatly appreciated. Thank you.