vasyabigi / angular-nouislider

Simple angular directive for jquery nouislider plugin
http://vasyabigi.github.io/angular-nouislider/
MIT License
84 stars 53 forks source link

ability to call custom function after change event #16

Open mg1075 opened 10 years ago

mg1075 commented 10 years ago

Once the change event happens, I need a way to call a custom function.

Therefore, I think it would be beneficial to add another item to the isolated scope of the directive that gives a hook for the change event of uinoslider.

http://refreshless.com/nouislider/events-callbacks#change

actionAfterChange: '&'

...

            slider.on('change', function () {
                if (scope.actionAfterChange !== undefined) {
                    scope.actionAfterChange(scope);
                }
            });
<div slider  ng-model="test.live" ... action-after-change="myCustomAction()"></div>

Then call myCustomAction in controller.

taivo commented 9 years ago

I agree that it would be cool to have this feature. I created a more general issue #23 before seeing this one.

Just in case all you need is a way to track ONE event (in your case, change), you can do this:

    <div slider ng-model="test.single" start=1 end=10 callback='change'></div>

and set up a scope.$watch on test.single

   scope.$watch('test.single', actionAfterChange)