From 0e76d9564222db4b77f70b43a129effe21e4ad60 Mon Sep 17 00:00:00 2001 From: Daniel Golub Date: Sat, 23 Jan 2016 20:22:12 +0200 Subject: [PATCH] Event for refreshing the Switcher Refresh the Switchery element if the digest cycle don't update it for some reason. --- src/ng-switchery.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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() {