Reputation: 31
I am using Angluar with material design, i am facing some issue, so the question is how to make material slider disabled on some specific value
<mat-slider min="1" max="5" step="0.5" value="{{myVar}}"></mat-slider>
I need to show it on my component with some specific value that comes from db, and can not be changed until it will change into db.
Upvotes: 2
Views: 6571
Reputation: 441
Adding style="pointer-events: none;"
will prevent the value from changing
<mat-slider style="pointer-events: none;" min="1" max="5" step="0.5" value="{{myVar}}" ></mat-slider>
Upvotes: 0
Reputation: 9815
So let us say you have a model that looks like this
export interface MyModel {
someValue: number;
}
And you load it within your component using some service that calls your API. Just pass the condition via disabled input to it.
<mat-slider [disabled]="myModel.someValue > 50" min="1" max="5" step="0.5" value="{{myVar}}"></mat-slider>
Upvotes: 6
Reputation: 1955
Actually you can just use disabled
as like this
<mat-slider min="1" max="5" disabled step="0.5" value="{{myVar}}"></mat-slider>
not big deal.
Upvotes: 3