I'm working on a project where I have an input field. Below this input field, there is a switch, if the switch is disabled, the input field is readonly.
Currently, I have the following solution, which does the job but is not nice. (If I use the switch, the input field disparat for some seconds):
app.component.html
<input *ngIf="isReadonly" readonly type="text"[formControl]="title">
<input *ngIf="!isReadonly" type="text" [formControl]="title">
<div class="switch form-switch" role="switch">
<input type='checkbox' id='switch' (click)="switch()">
<label for='title_switch'>{{'CUSTOM_TITLE_SWITCH'|translate}}</label>
</div>
app.component.ts
isReadonly = true
switch() {
this.isReadonly = !this.isReadonly
}
As I said, this solution works but it's not nice. Does anyone have a better idea?
Thanks!