mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 07:38:15 +00:00
[Forms] Use ng-model for tree state
Use ng-model when communicating state to/from the tree in browse mode. This will simplify implementation of the Locator control, which also uses a tree, but which should not set navigation state. WTD-593.
This commit is contained in:
@ -24,6 +24,7 @@ define(
|
||||
// that is currently navigated-to.
|
||||
function setNavigation(domainObject) {
|
||||
$scope.navigatedObject = domainObject;
|
||||
$scope.treeModel.selectedObject = domainObject;
|
||||
}
|
||||
|
||||
// Load the root object, put it in the scope.
|
||||
@ -48,30 +49,22 @@ define(
|
||||
}
|
||||
});
|
||||
|
||||
// Provide a model for the tree to modify
|
||||
$scope.treeModel = {
|
||||
selectedObject: navigationService.getNavigation()
|
||||
};
|
||||
|
||||
// Listen for changes in navigation state.
|
||||
navigationService.addListener(setNavigation);
|
||||
|
||||
// Also listen for changes which come from the tree
|
||||
$scope.$watch("treeModel.selectedObject", setNavigation);
|
||||
|
||||
// Clean up when the scope is destroyed
|
||||
$scope.$on("$destroy", function () {
|
||||
navigationService.removeListener(setNavigation);
|
||||
});
|
||||
|
||||
return {
|
||||
/**
|
||||
* Navigate to a specific domain object.
|
||||
*
|
||||
* This is exposed so that the browse tree has a callback
|
||||
* to invoke when the user clicks on a new object to navigate
|
||||
* to it.
|
||||
*
|
||||
* @method
|
||||
* @memberof BrowseController
|
||||
* @param {DomainObject} domainObject the object to navigate to
|
||||
*/
|
||||
setNavigation: function (domainObject) {
|
||||
navigationService.setNavigation(domainObject);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return BrowseController;
|
||||
|
Reference in New Issue
Block a user