Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove decimal point in slider min/max values #61

Open
CaptainChainsaw opened this issue Mar 17, 2015 · 4 comments
Open

How to remove decimal point in slider min/max values #61

CaptainChainsaw opened this issue Mar 17, 2015 · 4 comments

Comments

@CaptainChainsaw
Copy link

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
Copy link
Author

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
Copy link
Author

Sorted it, although its maybe a bit hacky:

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

@danielcrisp
Copy link
Owner

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"

@CaptainChainsaw
Copy link
Author

Ok thank you, much appreciated :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants