Created
April 6, 2013 19:54
-
-
Save arnaudbreton/5327394 to your computer and use it in GitHub Desktop.
AngularJS directive for bootstrap-switch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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