单击按钮将 mat-slider 的值更改为默认值

Change value of mat-slider to default value on click of button

<mat-slider thumbLabel min="0" max="100" step="1" value="0" >

<button type="button" (click)="Refresh()">Click Me!</button>

Refresh(){
// What should be written in this

}

假设我更改了这个滑块,当我点击刷新按钮时,我需要再次将值调整为零

谁能解释一下怎么做..

谢谢你....!!!!

只需将值添加为 ngModel 即可根据需要进行更改

Here 是一个 stackblitz 示例

ts

value: number = 0

Refresh(){
  this.value = 0
}

html

<mat-slider thumbLabel min="0" max="100" step="1" [(ngModel)]="value" ></mat-slider>
<button type="button" (click)="Refresh()">Click Me!</button>