danielcrisp / angular-rangeslider

Simple directive that creates a range slider for Angular, styled to match Bootstrap-styled form elements
danielcrisp.github.io/angular-rangeslider/
MIT License
223 stars 122 forks source link

use filter to convert value to hh:mm #29

Closed akuales closed 10 years ago

akuales commented 10 years ago

I would like to display a range between two hh:mm values. What I did now, was converting the values into numbers representing the minutes, like:

is it possible converting the display of the values to something like: parseInt(time/60)+':'+((time%60 > 10) ? (time%60) : '0'+(time%60) using the filter? I couldn't find any help on how to use the filter, except for the currency example.

danielcrisp commented 10 years ago

You should be able to create a custom filter (https://docs.angularjs.org/guide/filter) and then use that in the filter attribute.

For example if you created a filter called time you would then use this attribute: filter="time"

You can see how the filters are applied in the source here: https://github.com/danielcrisp/angular-rangeslider/blob/master/angular.rangeSlider.js#L348-L350

akuales commented 10 years ago

Thank you very much, for your answer! now everything works like a charm!