function () {

          attrs.$observe('switchActive', function (newValue) {

            var active = getBooleanFromStringDefTrue(newValue);
            // if we are disabling the switch, delay the deactivation so that the toggle can be switched
            if (!active) {
              $timeout(setActive);
            } else {
              // if we are enabling the switch, set active right away
              setActive();
            }
          });

          // When the model changes
          controller.$render = function () {
            initMaybe();
            var newValue = controller.$modelValue;
            if (newValue !== undefined && newValue !== null) {
              element.bootstrapSwitch('state', newValue === getTrueValue(), true);
            } else {
              element.bootstrapSwitch('indeterminate', true, true);
              controller.$setViewValue(undefined);
            }
            switchChange();
          };

          // angular attribute to switch property bindings
          var bindings = {
            'switchRadioOff': 'radioAllOff',
            'switchOnText': 'onText',
            'switchOffText': 'offText',
            'switchOnColor': 'onColor',
            'switchOffColor': 'offColor',
            'switchAnimate': 'animate',
            'switchSize': 'size',
            'switchLabel': 'labelText',
            'switchIcon': 'labelText',
            'switchWrapper': 'wrapperClass',
            'switchHandleWidth': 'handleWidth',
            'switchLabelWidth': 'labelWidth',
            'switchInverse': 'inverse',
            'switchReadonly': 'readonly'
          };

          var observeProp = function(prop, bindings) {
            return function() {
              attrs.$observe(prop, function () {
                setSwitchParamMaybe(element, bindings[prop], prop);
              });
            };
          };

          // for every angular-bound attribute, observe it and trigger the appropriate switch function
          for (var prop in bindings) {
            attrs.$observe(prop, observeProp(prop, bindings));
          }
        }
function () {

          attrs.$observe('switchActive', function (newValue) {

            var active = getBooleanFromStringDefTrue(newValue);
            // if we are disabling the switch, delay the deactivation so that the toggle can be switched
            if (!active) {
              $timeout(setActive);
            } else {
              // if we are enabling the switch, set active right away
              setActive();
            }
          });

          // When the model changes
          controller.$render = function () {
            initMaybe();
            var newValue = controller.$modelValue;
            if (newValue !== undefined && newValue !== null) {
              element.bootstrapSwitch('state', newValue === getTrueValue(), true);
            } else {
              element.bootstrapSwitch('indeterminate', true, true);
              controller.$setViewValue(undefined);
            }
            switchChange();
          };

          // angular attribute to switch property bindings
          var bindings = {
            'switchRadioOff': 'radioAllOff',
            'switchOnText': 'onText',
            'switchOffText': 'offText',
            'switchOnColor': 'onColor',
            'switchOffColor': 'offColor',
            'switchAnimate': 'animate',
            'switchSize': 'size',
            'switchLabel': 'labelText',
            'switchIcon': 'labelText',
            'switchWrapper': 'wrapperClass',
            'switchHandleWidth': 'handleWidth',
            'switchLabelWidth': 'labelWidth',
            'switchInverse': 'inverse',
            'switchReadonly': 'readonly'
          };

          var observeProp = function(prop, bindings) {
            return function() {
              attrs.$observe(prop, function () {
                setSwitchParamMaybe(element, bindings[prop], prop);
              });
            };
          };

          // for every angular-bound attribute, observe it and trigger the appropriate switch function
          for (var prop in bindings) {
            attrs.$observe(prop, observeProp(prop, bindings));
          }
        }
function ( ) { attrs . $observe ( 'switchActive' , function ( newValue ) { var active = getBooleanFromStringDefTrue ( newValue ) ; // if we are disabling the switch, delay the deactivation so that the toggle can be switched if ( ! active ) { $timeout ( setActive ) ; } else { // if we are enabling the switch, set active right away setActive ( ) ; } } ) ; // When the model changes controller . $render = function ( ) { initMaybe ( ) ; var newValue = controller . $modelValue ; if ( newValue !== undefined && newValue !== null ) { element . bootstrapSwitch ( 'state' , newValue === getTrueValue ( ) , true ) ; } else { element . bootstrapSwitch ( 'indeterminate' , true , true ) ; controller . $setViewValue ( undefined ) ; } switchChange ( ) ; } ; // angular attribute to switch property bindings var bindings = { 'switchRadioOff' : 'radioAllOff' , 'switchOnText' : 'onText' , 'switchOffText' : 'offText' , 'switchOnColor' : 'onColor' , 'switchOffColor' : 'offColor' , 'switchAnimate' : 'animate' , 'switchSize' : 'size' , 'switchLabel' : 'labelText' , 'switchIcon' : 'labelText' , 'switchWrapper' : 'wrapperClass' , 'switchHandleWidth' : 'handleWidth' , 'switchLabelWidth' : 'labelWidth' , 'switchInverse' : 'inverse' , 'switchReadonly' : 'readonly' } ; var observeProp = function ( prop , bindings ) { return function ( ) { attrs . $observe ( prop , function ( ) { setSwitchParamMaybe ( element , bindings [ prop ] , prop ) ; } ) ; } ; } ; // for every angular-bound attribute, observe it and trigger the appropriate switch function for ( var prop in bindings ) { attrs . $observe ( prop , observeProp ( prop , bindings ) ) ; } }
Listen to model changes.
Listen to model changes .