diff --git a/platform/commonUI/general/src/controllers/ObjectInspectorController.js b/platform/commonUI/general/src/controllers/ObjectInspectorController.js index 95924add34..d8e6ead840 100644 --- a/platform/commonUI/general/src/controllers/ObjectInspectorController.js +++ b/platform/commonUI/general/src/controllers/ObjectInspectorController.js @@ -24,8 +24,8 @@ * Module defining ObjectInspectorController. Created by shale on 08/21/2015. */ define( - ['angular'], - function (angular) { + [], + function () { /** * The ObjectInspectorController gets and formats the data for @@ -38,8 +38,6 @@ define( $scope.contextutalParents = []; //$scope.isLink = false; - this.InspectorMutation = $scope.ngModel.selectedObject.getCapability('mutation'); - // Gets an array of the contextual parents/ancestors of the selected object function getContextualPath() { var currentObj = $scope.ngModel.selectedObject, @@ -111,11 +109,9 @@ define( getMetadata(); }); - this.InspectorMutation.listen(function () { - if (!angular.equals($scope.metadata, $scope.ngModel.selectedObject.useCapability('metadata'))) { - getMetadata(); - } - }); + var mutation = $scope.ngModel.selectedObject.getCapability('mutation'); + var unlisten = mutation.listen(getMetadata); + $scope.$on('$destroy', unlisten); } return ObjectInspectorController; } diff --git a/platform/commonUI/general/test/controllers/ObjectInspectorControllerSpec.js b/platform/commonUI/general/test/controllers/ObjectInspectorControllerSpec.js index be970c44f8..4178fa8581 100644 --- a/platform/commonUI/general/test/controllers/ObjectInspectorControllerSpec.js +++ b/platform/commonUI/general/test/controllers/ObjectInspectorControllerSpec.js @@ -39,7 +39,7 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj( "$scope", - ["$watch"] + ["$watch", "$on"] ); mockScope.ngModel = {}; mockScope.ngModel.selectedObject = {