diff --git a/src/ng-switchery.js b/src/ng-switchery.js index 9367900..66deb65 100644 --- a/src/ng-switchery.js +++ b/src/ng-switchery.js @@ -5,7 +5,7 @@ * @TODO implement Switchery as a service, https://github.com/abpetkov/switchery/pull/11 */ angular.module('NgSwitchery', []) - .directive('uiSwitch', ['$window', '$timeout','$log', '$parse', function($window, $timeout, $log, $parse) { + .directive('uiSwitch', ['$window', '$timeout','$log', '$parse', '$rootScope', function($window, $timeout, $log, $parse, $rootScope) { /** * Initializes the HTML element as a Switchery switch. @@ -39,6 +39,10 @@ angular.module('NgSwitchery', []) switcher.enable(); } }); + + $rootScope.$on("uiSwitch.refresh", function(event, payload) { + initializeSwitch(); + }) function initializeSwitch() { $timeout(function() {