Home > Net >  Forcing a mat-slide-toggle to be true with formControl
Forcing a mat-slide-toggle to be true with formControl

Time:10-26

Is there a way to force the mat-slide-toggle to be true under a condition. (If someone tries to make it false, either it doesnt budge, or it goes back to true instantly). Something functionally equivalent to forcedTrue="someCondtion" in

<mat-slide-toggle
    formControlName="compression"
    
    forcedTrue="someCondtion">
    {{'compression' | translate}}
</mat-slide-toggle>

CodePudding user response:

Use [checked]="true" [disabled]="true"

   <mat-slide-toggle
    formControlName="compression"
    
    [checked]="true"
    [disabled]="true">
    {{'compression' | translate}}
  </mat-slide-toggle>
  • Related