Angular Directive for Bootstrap-Switch

Have you seen the Bootstrap Switch? If not, check it out:

Awesome!

Angular Directive

Once you’ve added bootstrap-switch to your project, simply add this directive to your app.js or controller.

Usage

<input type="checkbox" ng-model="mymodel.mystate" bootstrap-switch />

WARNING I can’t stress this enough:

“Always use a dot in your ng-model”

  • A war-torn, battle-scarred, mentally-exhausted person who didn’t do exactly this

Scoping and binding are potentially screwed if you don’t. It is a difficult problem to find and understand.

Further reading is required: https://github.com/angular/angular.js/wiki/Understanding-Scopes

http://stackoverflow.com/questions/17178943/does-my-ng-model-really-need-to-have-a-dot-to-avoid-child-scope-problems

http://stackoverflow.com/questions/18128323/angularjs-if-you-are-not-using-a-dot-in-your-models-you-are-doing-it-wrong