Search code examples
javascripthtmlangularangular-materialangular15

Mat Slider Value in Angular 15


The code used to work in Angular 14 but is not working in Angular 15.

    <mat-slider
            min="1"
            max="150"
            step="10"
            value="55"
            #itemHeight
     >
     </mat-slider>

     <label> {{ itemHeight.value  }} hie </label>

StackBlitz link => https://stackblitz.com/edit/angular-ixbgdr?file=src%2Fmain.ts


Solution

  • You now have to pass an input to the slider :

      <mat-slider min="1" max="5" step="0.5" value="1.5">
         <input matSliderThumb #itemHeight>
      </mat-slider>
    
      <label>  {{itemHeight.value}} </label>