Skip to main content

angular material - How to use Slide toggle

app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})


export class AppComponent { 
  isChecked:boolean = false;
}
app.component.html

<h2 style="padding-top:25px; padding-bottom:25px;">
    Angular Material - How to use Slide toggle
</h2>


<h3>Checked status : {{isChecked}}</h3>

<mat-slide-toggle [(ngModel)]="isChecked">
    Enable Wifi
</mat-slide-toggle>
app.module.ts [import]

import { MatSlideToggleModule } from '@angular/material/slide-toggle'
import { FormsModule } from '@angular/forms';
More Angular tutorials