darul75 / angular-awesome-slider

:arrows_clockwise: Angular slider control directive
http://darul75.github.io/angular-awesome-slider/
MIT License
144 stars 63 forks source link

Using dates as values #95

Open emiguevara opened 9 years ago

emiguevara commented 9 years ago

I want to use ng-slider as a date selector. Passing Unix timestamps to the slider works just perfect, and the step option is very useful too. However, I would like to transform the timestamps into date objects in order to show human readable dates on the interface.

Any experience or suggestions on how to do this? Or is it a case for a fork and pull request? Thanks!

darul75 commented 9 years ago

Momentjs do that very well. But not sure then values displayed can be different from original value, date object in your case. Can you fork jsfiddle with your case.

emiguevara commented 9 years ago

I made a jsfiddle with a couple of examples https://jsfiddle.net/emiguevara/c5zf73gd/1/

If ng-model receives a date object, the slider breaks. I suppose a trick could be to make the slider work with the Unix timestamps and creating the date object just for the HTML... I hope I made myself clear, thanks!

darul75 commented 9 years ago

Today only number or string (mandatory for range pattern) are handled for model value. To pass object or and array of object looks fine to handle a Date model. But then display would be a simple toString method for js dates. I have to think about it but quite busy now. You can start do play with src/ng-slider.js with a single Date object and change test made with string or number.

emiguevara commented 9 years ago

Thanks, looking at the code to see if I understand something... man, this is dense...

darul75 commented 9 years ago

Yeah fu... dense because original was ;) and I have put time understand split try break again and...but that's js world crazy one. When u fork u can use index.html file in src folder with some breakpoint you may have fun or not.

darul75 commented 9 years ago

some contributors have added 'modelLabels' option, it accept an object today but I will see to enhance it to support a function which will convert a date timestamp value to string of your choice by instance (with momentjs or whatever ;))

kavka3 commented 8 years ago

++