angularjs-slider icon indicating copy to clipboard operation
angularjs-slider copied to clipboard

Default values for range slider with stepsArray

Open PedroF20 opened this issue 10 years ago • 2 comments

See my range slider here? image

I'm using a stepsArray that contains dates, and each step is a single day:

        $scope.slider = {
            minValue: 0,  
            maxValue: 1, 
            options: {
                stepsArray: getAllDays(), 
                noSwitching: true,
                translate: function(value, sliderId, label) {
                  switch (label) {
                    case 'model':
                        return '<b>Start date:</b> ' + value;
                    case 'high':
                        return '<b>End date:</b> ' + value;
                    case 'floor':
                        return '<b>Min date:</b> ' + value;
                    case 'ceil':
                        return '<b>Max date:</b> ' + value;
                  }
                }
            }
        };

I wish to start the slider on default with the max range, but it starts with both handles on the first date. Is there any way to pass the first and last dates to the minValue and maxValue?

PedroF20 avatar Aug 03 '16 14:08 PedroF20

Yes you just need to set these values in your $scope.slider object... If your getAllDays() returns an array, extract it before the slider config in a var and set minValue to var[0] and maxValue to var[var.length -1].

ValentinH avatar Aug 04 '16 05:08 ValentinH

It works. I'll close it. Thanks.

PedroF20 avatar Aug 04 '16 11:08 PedroF20