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

Binding the "from" and "to" bounds of the slider #60

Closed pbruneau closed 9 years ago

pbruneau commented 9 years ago

Hi all,

Currently, the data binding takes place for the ng-model attribute, but not for properties of the options attribute - i.e., referring to your "single value" example on github pages, if $scope.options.to is modified later on, the changes won't be reflected on the input component - am I right?

If so, is such a feature under consideration? Or someone might have a pretty straightforward workaround?

Thanks by advance!

darul75 commented 9 years ago

hi @pbruneau

you can change dynamically options and see slider updated, scale ... check demo here in source directory, just open it

https://github.com/darul75/ng-slider/blob/master/src/ng-slider.html

pbruneau commented 9 years ago

OK, I know where I got it wrong : with reference to your code, I was attempting to use:

$scope.options.to = myVar;

i.e. I was assuming your lib was "deep-watching" the options object. Fixed now, I guess the issue is closed.

mjanderson235 commented 9 years ago

I've been having the same problem. I can play with the jsFiddle page you provided (http://jsfiddle.net/darul75/g9e9n8xc/), just adding in a button with an ng-change to use the changeOptions() function, and everything works fine.

However, when I try to get my options from a service, things go wrong. I'm calling the service within an ng-repeat, so I need separate options for each slider. I'll change the to and from options, and the console log shows that they have been changed. When I change the position on the slider, the callback function tells me that the to and from values have still changed to the new values - but the display still shows the original values, the pointer still behaves according to the original values, and the to and from reset to the original values immediately upon changing the slider.

(Working on getting a JSFiddle up that reproduces the problem. It currently doesn't want to misbehave for me appropriately.)

mjanderson235 commented 9 years ago

Here's a JSFiddle for the problem (though it works, unlike my webpage; it should be pretty much the same thing however): http://jsfiddle.net/mjanderson235/ynbsjs8o/6/

darul75 commented 9 years ago

hi, sorry I can not look deeply, leaving for one week tonight, I have just changed behaviour here http://jsfiddle.net/g9e9n8xc/53/

mjanderson235 commented 9 years ago

Yeah, I realized after submitting the comment that I had accidentally gone back to the old way of trying to change the scale. The JSFiddle works when you swap out the options like in your example, but the web page on my server still does not.

darul75 commented 9 years ago

I try to reproduce it when I got time and be back home

darul75 commented 9 years ago

as for options object it looks fine, now watch is made by value and not just by reference so it will works, coming in 2.1.9 version

darul75 commented 9 years ago

https://github.com/darul75/ng-slider/releases/tag/2.1.9