Ben Cull - Payments Engineer and Microsoft Development Professional

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

Angular Directive for Bootstrap-Switch
Prev post

IE is caching my AngularJS requests to ASP.NET MVC

Next post

Handling Validation Errors with AngularJS and ASP.NET MVC

Angular Directive for Bootstrap-Switch

Get in touch

Send me a message and I'll get back to you.