Skip to content

Instantly share code, notes, and snippets.

@blair55
Created April 18, 2013 21:05
Show Gist options
  • Save blair55/5416216 to your computer and use it in GitHub Desktop.
Save blair55/5416216 to your computer and use it in GitHub Desktop.
Linked Slider AngularJS Directive using JQuery UI
app.directive('linkedSlider', function () {
return {
restrict: 'A',
scope: {
value: '=',
link: '=',
step: '@',
min: '@',
max: '@',
condition: '&'
},
link: function(scope, element) {
setTimeout(function() {
$(element).slider({
min: parseInt(scope.min),
max: parseInt(scope.max),
step: parseInt(scope.step),
value: parseInt(scope.value),
slide: function(event, ui) {
scope.$apply(function() { scope.value = ui.value; });
if (scope.condition()) {
scope.$apply(function() { scope.link = ui.value; });
}
}
});
scope.$watch('value', function(newValue) {
$(element).slider('value', newValue);
});
scope.$watch('link', function(newValue) {
});
}, 1);
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment