angular-ui / ui-slider

jQuery UI Slider for AngularJS
https://htmlpreview.github.io/?https://github.com/angular-ui/ui-slider/master/demo/index.html
MIT License
265 stars 176 forks source link

Changing min/max values after slider creation? #97

Open akashihi opened 8 years ago

akashihi commented 8 years ago

Is it possible to change max value when slider is already created and used?

I tried that approach:

$scope.slider = {
    options: {
        range: false,
        min: 1,
        max: $scope.selectedQuant.maxValue,
        step: 1
    }
};

[....skip...] $scope.slider.options.max = $scope.selectedQuant.maxValue

but it doesn't works.

Alexabix commented 8 years ago

Works for me, although it doesn't generate new "ticks" if you have that option enabled. <div ui-slider data-min="0" data-max="{{attributeCount - 1}}" data-step="1" data-tick ng-model="sliderValue"></div>

When I add new objects to my collection I update the count the data-max attribute uses. It didn't work when I set it to attributes.length so I added the watchCollection. $scope.$watchCollection("attributes", function () { $scope.attributeCount = $scope.attributes.length; });