Some basic demos to get you going.
Note: As this is demonstrating legacy support all two-way property bindings (i.e. '=') must be defined on the directive, for example disabled is no longer an optional attribute.
$scope.demo1 = {
min: 20,
max: 80
};
<div range-slider min="0" max="100" model-min="demo1.min" model-max="demo1.max" disabled="false"></div>
<div range-slider orientation="vertical" min="0" max="100" model-min="demo1.min" model-max="demo1.max" disabled="false"></div>
And here are the values in our model being updated: Min Max
$scope.demo2 = {
range: {
min: 0,
max: 10050
},
minPrice: 1000,
maxPrice: 4000
};
Here we are using the filter, filter-options and step options.
<div range-slider min="demo2.range.min" max="demo2.range.max" model-min="demo2.minPrice" model-max="demo2.maxPrice" filter="currency:'$'" step="100" disabled="false"></div>
$scope.demo3 = {
_min: 25,
_max: 75,
min: function(newValue) {
return arguments.length ? ($scope.demo3._min = newValue) : $scope.demo3._min;
},
max: function(newValue) {
return arguments.length ? ($scope.demo3._max = newValue) : $scope.demo3._max;
}
};
Here we are using the getter-setter option allowing us to provide getterSetter methods to model-min and model-max
<div range-slider min="0" max="100" model-min="demo3.min" model-max="demo3.max" getter-setter="true" disabled="false"></div>
$scope.demo4 = {
rangeMin: 10,
rangeMax: 1500,
min: 80,
max: 1000,
disabled: false
};
$scope.demo5 = {
min: 300,
max: 800
};
<div range-slider orientation="vertical left" min="0" max="1000" model-min="demo5.min" model-max="demo5.max" disabled="false"></div>
<div range-slider orientation="vertical right" min="0" max="1000" model-min="demo5.min" model-max="demo5.max" disabled="false"></div>
$scope.demo6 = {
min: 80,
max: 1000
};
You can hide the slider values if you wish to display the values elsewhere.
Maybe you'd prefer to show the values in sentence form... Your current minimum value is {{demo6.min}} and your current maximum value is {{demo6.max}}.
<div range-slider min="0" max="10000" model-min="demo6.min" model-max="demo6.max" show-values="false" disabled="false"></div>
$scope.demo7 = {
valueA: 5000,
valueB: 3000
};
You many 'pin' (and hide) either the minimum or maximum handle to prevent it from being modified, effectivly converting the slider into a single-value slider.
The value of the first slider is: {{demo7.valueA}}; the second slider is {{demo7.valueB}}.
<div range-slider min="0" max="10000" model-min="0" model-max="demo7.valueA" pin-handle="min" disabled="false"></div>
<div range-slider min="0" max="10000" model-min="demo7.valueB" model-max="10000" pin-handle="max" disabled="false"></div>
$scope.demo8 = {
range: {
min: 0,
max: 10050
},
minPrice: 1000,
maxPrice: 4000
};
You can prevent the two values from being equal by using the prevent-equal-min-max="true" attribute. The step value is used to maintain a gap between the values, so if the step is set to 100 the minimum difference will be 100. If no step value is provided a minimum difference of 1 will be used.
Here we are using the step and prevent-equal-min-max options.
<div range-slider min="demo8.range.min" max="demo8.range.max" model-min="demo8.minPrice" model-max="demo8.maxPrice" step="100" prevent-equal-min-max="true" disabled="false"></div>
$scope.demo9 = {
max: 5000,
min: 3000
};
You can make the values move with the handles as they slide by setting attach-handle-values to true.
<div range-slider min="0" max="10000" model-min="demo9.min" model-max="demo9.max" attach-handle-values="true" disabled="false"></div>