Get Angular Material v2 slider's value while sliding

*爱你&永不变心* 提交于 2019-12-04 01:34:04
DevVersion

Great question. Such a functionality has been added to Angular Material. See this commit.

In your case, you would not listen to the (change) event but rather to the (input) event. Here is an example:

<mat-slider (input)="onInputChange($event)"></mat-slider>
onInputChange(event: MatSliderChange) {
  console.log("This is emitted as the thumb slides");
  console.log(event.value);
}

I was trying to get mat-slider value inside of my component, and I got it by using event.value as shown below. Submitted this answer to help someone like me :) Thanks

<md-slider (input)="onInputChange($event)"></md-slider>

onInputChange(event: any) {
  console.log(event.value);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!