How can I set a default value for the slide toggle?
I can set an initial value for my property in ngOnInit, but there must be an 'Angular Way'
<mat-slide-toggle
[checked]="system.ignoreUser"
(toggleChange)="system.ignoreUser= !system.ignoreUser">
<span *ngIf="system.ignoreUser">{{'ignoreUser' | translate}}</span>
<span *ngIf="!system.ignoreUser">{{'ignoreUser' | translate}}</span>
</mat-slide-toggle>
Thank you!
You can use checked input property:
<mat-slide-toggle [checked]="true"></mat-slide-toggle>
You can just use ngModel in your html:
<mat-slide-toggle [(ngModel)]="system.ignoreUser">
<span *ngIf="system.ignoreUser">{{'ignoreUser' | translate}}</span>
<span *ngIf="!system.ignoreUser">{{'ignoreUser' | translate}}</span>
</mat-slide-toggle>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With