Skip to content

Instantly share code, notes, and snippets.

@fritzvd
Created June 21, 2013 10:24
Show Gist options
  • Save fritzvd/5830321 to your computer and use it in GitHub Desktop.
Save fritzvd/5830321 to your computer and use it in GitHub Desktop.
Angular JS jQuery UI Slider
<jq-schlider ng-enabled="state.master" at="time.at" max="time.max_timestep"></jq-schlider>
<script>
angular
.module('Components', [])
.directive('jqSchlider', function () {
return {
restrict: 'E',
replace: true,
template: '<div id="schlider"></div>',
scope: {
'ngEnabled': '=',
'max': '=',
'at': '='
},
link: function (scope, element, attrs) {
element.slider({
stop : function(event, ui) {}
});
element.on('slidestop', function(event, ui){
scope.$apply(function(){
scope.$parent.time.at = ui.value;
});
});
scope.$watch('max', function (value) {
element.slider('option', 'max', value);
});
scope.$watch('at', function (value) {
element.slider('option', 'value', value);
});
scope.$watch('ngEnabled', function (value) {
element.attr('enabled', value);
if (value) {
element.slider('enable');
}
else {
element.slider('disable');
}
});
}
};
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment