For some of my components I would like to change input field readonly and required attributes back and forth.
I\'ve managed to get a running code, that changes both of
For bound attributes to be removed they need to be set to null. There was a discussion to change it to remove on false but it was declined, at least for now.
[required]="isRequired ? '' : null"
or
[required]="isRequired ? 'required' : null"
Your Plunker produces an error because of missing []
around ngControl
.
See also this Plunker for a working example
See also Deilan's comments below.