File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed
Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 1212 < mat-slide-toggle labelPosition ="before " [disabled] ="firstToggle "> Disable Bound</ mat-slide-toggle >
1313 < mat-slide-toggle labelPosition ="before " hideIcon [(ngModel)] ="firstToggle "> No icon</ mat-slide-toggle >
1414
15+ < p > With no label.</ p >
16+
17+ < mat-slide-toggle aria-label ="Toggle only " hideLabel color ="primary " [(ngModel)] ="firstToggle " />
18+
1519 < p > Example where the slide toggle is required inside of a form.</ p >
1620
1721 < form #form ="ngForm " (ngSubmit) ="onFormSubmit() ">
Original file line number Diff line number Diff line change 5757 Clicking on the label will trigger another click event from the button.
5858 Stop propagation here so other listeners further up in the DOM don't execute twice.
5959 -->
60- < label class ="mdc-label " [for] ="buttonId " [attr.id] ="_labelId " (click) ="$event.stopPropagation() ">
61- < ng-content > </ ng-content >
62- </ label >
60+ @if (!hideLabel) {
61+ < label class ="mdc-label " [for] ="buttonId " [attr.id] ="_labelId " (click) ="$event.stopPropagation() ">
62+ < ng-content > </ ng-content >
63+ </ label >
64+ }
6365</ div >
Original file line number Diff line number Diff line change @@ -183,6 +183,9 @@ export class MatSlideToggle
183183 this . _changeDetectorRef . markForCheck ( ) ;
184184 }
185185
186+ /** Whether to hide the icon inside of the slide toggle. */
187+ @Input ( { transform : booleanAttribute } ) hideLabel : boolean ;
188+
186189 /** Whether to hide the icon inside of the slide toggle. */
187190 @Input ( { transform : booleanAttribute } ) hideIcon : boolean ;
188191
You can’t perform that action at this time.
0 commit comments