thingsboard-aplcache

Details

diff --git a/ui/src/app/dashboard/dashboard.controller.js b/ui/src/app/dashboard/dashboard.controller.js
index 5772f35..8319a9d 100644
--- a/ui/src/app/dashboard/dashboard.controller.js
+++ b/ui/src/app/dashboard/dashboard.controller.js
@@ -264,6 +264,10 @@ export default function DashboardController(types, utils, dashboardUtils, widget
         }
     });
 
+    $scope.$on("$destroy", function () {
+        vm.dashboardCtx.stateController.cleanupPreservedStates();
+    });
+
     loadDashboard();
 
     function loadWidgetLibrary() {
diff --git a/ui/src/app/dashboard/states/states-component.directive.js b/ui/src/app/dashboard/states/states-component.directive.js
index 02d6fee..1f83a61 100644
--- a/ui/src/app/dashboard/states/states-component.directive.js
+++ b/ui/src/app/dashboard/states/states-component.directive.js
@@ -54,6 +54,10 @@ export default function StatesComponent($compile, $templateCache, $controller, s
                 }
             }
 
+            stateController.cleanupPreservedStates = function() {
+                statesControllerService.cleanupPreservedStates();
+            }
+
             stateController.navigatePrevState = function(index) {
                 if (scope.statesController) {
                     scope.statesController.navigatePrevState(index);
diff --git a/ui/src/app/dashboard/states/states-controller.service.js b/ui/src/app/dashboard/states/states-controller.service.js
index be695c3..b320b15 100644
--- a/ui/src/app/dashboard/states/states-controller.service.js
+++ b/ui/src/app/dashboard/states/states-controller.service.js
@@ -42,7 +42,8 @@ export default function StatesControllerService() {
         getStateControllers: getStateControllers,
         getStateController: getStateController,
         preserveStateControllerState: preserveStateControllerState,
-        withdrawStateControllerState: withdrawStateControllerState
+        withdrawStateControllerState: withdrawStateControllerState,
+        cleanupPreservedStates: cleanupPreservedStates
     };
 
     return service;
@@ -69,4 +70,10 @@ export default function StatesControllerService() {
         return state;
     }
 
+    function cleanupPreservedStates() {
+        for (var id in statesControllers) {
+            statesControllers[id].state = null;
+        }
+    }
+
 }