M D V Ajay kumar 360
M D V Ajay kumar 360

Reputation: 37

how to make text on the mat-slide-toggle

how to put text on mat-slide-toggle like when it is true I want to show it as assigned and when false not assigned

<mat-slide-toggle (click)="openDialog1(element.courseId, true )" [checked]="checked">Assign All</mat-slide-toggle> 

Upvotes: 0

Views: 1203

Answers (1)

Shyam Joshi
Shyam Joshi

Reputation: 923

Remove [checked]="checked" and use [(ngModel)] instead, and show html content based on the flag, like this -

<mat-slide-toggle (click)="openDialog1(element.courseId, true )" [(ngModel)]="checked">{{ checked ? 'assigned' : 'not assigned' }}</mat-slide-toggle>

Declare a flag in ts file -

checked: boolean;

Upvotes: 1

Related Questions