angular-rangeslider icon indicating copy to clipboard operation
angular-rangeslider copied to clipboard

How to remove decimal point in slider min/max values

Open CaptainChainsaw opened this issue 9 years ago • 4 comments

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 :)

CaptainChainsaw avatar Mar 17 '15 11:03 CaptainChainsaw

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?

CaptainChainsaw avatar Mar 17 '15 14:03 CaptainChainsaw

Sorted it, although its maybe a bit hacky:

.filter('decimalFilter', function () {
    return function (value) {
       return '£' + parseInt(value);
    };
  })

CaptainChainsaw avatar Mar 17 '15 14:03 CaptainChainsaw

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"

danielcrisp avatar Mar 24 '15 11:03 danielcrisp

Ok thank you, much appreciated :)

CaptainChainsaw avatar Mar 27 '15 09:03 CaptainChainsaw