diff --git a/ui/src/app/dashboard/dashboard.controller.js b/ui/src/app/dashboard/dashboard.controller.js index 5772f3519a..8319a9da89 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 02d6fee937..1f83a6187e 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 be695c3e1e..b320b15f80 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; + } + } + }