app.component.ts
import { Component } from '@angular/core';
import { MatSlider } from '@angular/material/slider';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styles: [`
mat-slider{
width: 400px;
}
`]
})
export class AppComponent {
value:number = 0;
oldValue:number = this.value;
message:string = "";
onSliderValueChange(slider:MatSlider){
this.message = "Slider value change from "
+ this.oldValue + " to " + slider.value;
this.oldValue = slider.value
}
}
app.component.html
<h2 style="padding-top:25px; padding-bottom:25px;">
Angular Material - How to use Slider change event
</h2>
<h3>Selected Value : {{value}}</h3>
<h3>{{message}}</h3>
<mat-slider
#slider
[(ngModel)]="value"
(change)="onSliderValueChange(slider)">
</mat-slider>
app.module.ts [import]
import { MatSliderModule } from '@angular/material/slider';
import { FormsModule } from '@angular/forms';
- angular material - How to use Slider
- angular material - Tick interval with step in Slider
- angular material - How to invert Slider
- angular material - How to show thumb label in Slider
- angular material - Slider custom formatted thumb label
- angular material - How to show Badge in a button
- angular material - How to show Badge with icon
- angular material - Badge position before & below after
- angular material - Determine an Expansion Panel is opened or closed
- angular material - Determine an Expansion Panel is disabled or enabled
- angular material - How to toggle Expansion Panel expanded state
- angular material - Navigation list with button and icon
- angular material - How to use Action List
- angular material - Action list with button and icon
- angular material - How to use Selection List