diff --git a/bower.json b/bower.json index c1edf2f..0f80686 100644 --- a/bower.json +++ b/bower.json @@ -15,7 +15,7 @@ "slide" ], "dependencies": { - "angular": "~1.2.6", + "angular": "~1.4.0", "jquery": "~2.1.0", "nouislider": "~6.2.0" }, diff --git a/src/nouislider.js b/src/nouislider.js index d9afa6c..3248839 100644 --- a/src/nouislider.js +++ b/src/nouislider.js @@ -10,16 +10,26 @@ angular.module('nouislider', []).directive('slider', function () { margin: '@', ngModel: '=', ngFrom: '=', - ngTo: '=' + ngTo: '=', + options: '=?' }, link: function (scope, element, attrs) { - var callback, fromParsed, parsedValue, slider, toParsed; + var callback, fromParsed, parsedValue, slider, toParsed, options = {}; + + if (scope.options) { options = scope.options; } + slider = $(element); + + function initSliderWithOptions(customOptions) { + slider.noUiSlider($.extend(options, customOptions)); + } + callback = scope.callback ? scope.callback : 'slide'; if (scope.ngFrom != null && scope.ngTo != null) { fromParsed = null; toParsed = null; - slider.noUiSlider({ + + initSliderWithOptions({ start: [ scope.ngFrom || scope.start, scope.ngTo || scope.end @@ -60,7 +70,7 @@ angular.module('nouislider', []).directive('slider', function () { }); } else { parsedValue = null; - slider.noUiSlider({ + initSliderWithOptions({ start: [scope.ngModel || scope.start], step: parseFloat(scope.step || 1), range: { @@ -82,4 +92,4 @@ angular.module('nouislider', []).directive('slider', function () { } } }; -}); \ No newline at end of file +});