frapontillo/angular-bootstrap-switch — pull request #27 by mjmvisser (2014-08-21 21:16:32+00:00)
Title: use controller.$viewValue (boolean) instead of $modelValue (anything) an...

Hi, thanks for writing this. It's a very clean wrapper. I found it didn't work out of the box, though (especially the version in bower). Here are a few minor changes I made that simplify the directive and fix a small refresh bug:

1. instead of computing the true value using attrs.ngTrueValue and comparing that against the model, just use controller.$viewValue. The input already does this calculation, so why not take advantage of it?

2. instead of using $formatters to update the switch, use $viewChangeListeners. This fixed a refresh problem I was having.

3. pass the $viewValue as the initial state. It just works.

cheers,
-Mark