Skip to content

Instantly share code, notes, and snippets.

@hitautodestruct
Created October 8, 2013 10:10
Show Gist options
  • Save hitautodestruct/6882549 to your computer and use it in GitHub Desktop.
Save hitautodestruct/6882549 to your computer and use it in GitHub Desktop.
Angularjs directive for simplifying bootstrap buttons. Removes the need to add a `class="btn btn-lg btn-success"` etc. http://jsbin.com/ibinASA/1/edit
var app = angular.module('boostrapButton', []);
app.directive('btn', function () {
return function ( scope, element, attrs ) {
var classes = attrs.btn.split(' ');
classes.unshift('btn');
element.addClass( classes.join(' btn-') );
};
});
@hitautodestruct
Copy link
Author

Works like this:

 <div ng-app="boostrapButton">

    <button btn="lg success">Testing the test</button>

 </div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment