angular-rangeslider
angular-rangeslider copied to clipboard
How to remove decimal point in slider min/max values
Hi,
How can I remove the decimal numbers from the min and max range values. I set the min to "50" and max to "10000" but the slider shows "50.00" and "10000.00" , I need "50" and "10000".
How would I do this?
This is my code at the moment:
<div range-slider min="demo.minPrice" max="demo.maxPrice" model-min="sliderRanges.min" model-max="sliderRanges.max" decimal-places="0" filter="currency" filter-options="£" step="10" disabled="false"></div>
Thank you in advance :)
Got it sorted, changed my code to include a filter. Unfortunately I can't show the currency symbol:
<div range-slider min="demo.minPrice" max="demo.maxPrice" model-min="sliderRanges.min" model-max="sliderRanges.max" filter="decimalFilter" step="10" disabled="false"></div>
.filter('decimalFilter', function () {
return function (value) {
return parseInt(value);
};
})
Only problem with this is I can't seem to have the currency symbol as would mean adding:
filter="currency" filter-options="£"
If I add the above code it doesn't add the currency symbol.
Any ideas?
Sorted it, although its maybe a bit hacky:
.filter('decimalFilter', function () {
return function (value) {
return '£' + parseInt(value);
};
})
I think the currency
filter defaults to two decimal places, if you want to change that you can set the fractionSize
option if your version of Angular supports it.
https://docs.angularjs.org/api/ng/filter/currency
I think it might be something like this (untested)
filter="currency:'£':0"
Ok thank you, much appreciated :)