Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Setting value in mat-slider

How to set an initial value on the angular range slider?

According to the Angular material documentation, the code should be like this:

<mat-slider min="1" max="5" step="0.5" value="1.5">
  <input matSliderThumb>
</mat-slider>

However, it does not seem to set a default value.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Here is the stackblitz provided by the angular documentation, with the attributes added: https://stackblitz.com/edit/7nqkex?file=src%2Fexample%2Fslider-overview-example.html

>Solution :

You have a input inside themat-slider, so you should put the value there, not to <mat-slider>.

Try this:

<mat-slider min="1" max="5" step="0.5">
  <input matSliderThumb value="1.5" />
</mat-slider>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading