diff --git a/ngStorage.js b/ngStorage.js index 09174ba..c5c5783 100644 --- a/ngStorage.js +++ b/ngStorage.js @@ -87,13 +87,15 @@ '$log', '$timeout', '$document', + '$injector', function( $rootScope, $window, $log, $timeout, - $document + $document, + $injector ){ function isStorageSupported(storageType) { @@ -212,6 +214,18 @@ $storage.$apply(); }); + if ($injector.has('$state')) { + $rootScope.$on('$stateChangeStart', function () { + $storage.$apply(); + }); + } + + if ($injector.has('$route')) { + $rootScope.$on('$routeChangeStart', function() { + $storage.$apply(); + }); + } + return $storage; } ];