Skip to content

Instantly share code, notes, and snippets.

@arnaudbreton
Created April 6, 2013 19:54
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnaudbreton/5327394 to your computer and use it in GitHub Desktop.
Save arnaudbreton/5327394 to your computer and use it in GitHub Desktop.
AngularJS directive for bootstrap-switch
<div class="switch switch-small" bootstrap-switch="sync">
<input id="syncswitch" type="checkbox" />
</div>
module.directive('bootstrapSwitch', function() {
return {
restrict:'A',
scope: {
sync: true
},
link: function(scope, element, attrs) {
$(element).bootstrapSwitch();
$(element).bootstrapSwitch('setState', attrs.bootstrapSwitch);
$(element).on('switch-change', function (e, data) {
scope.sync = data.value;
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment