mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 13:43:09 +00:00
[Addressability] Update route without reinstantiating
Work around normal behavior of Angular when path changes; instead of reinstantiating controller for Browse mode when Browse-initiated path changes occur, act as if the route hadn't changed (so that the URL updates but the currently-displayed state, e.g. tree expansion, is preserved.) WTD-1149.
This commit is contained in:
parent
084d6b6859
commit
3738ea16d7
@ -41,9 +41,9 @@ define(
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function BrowseController($scope, $routeParams, $location, objectService, navigationService) {
|
||||
function BrowseController($scope, $route, $location, objectService, navigationService) {
|
||||
var path = [ROOT_ID].concat(
|
||||
($routeParams.ids || DEFAULT_PATH).split("/")
|
||||
($route.current.ids || DEFAULT_PATH).split("/")
|
||||
);
|
||||
|
||||
function updateRoute(domainObject) {
|
||||
@ -51,6 +51,12 @@ define(
|
||||
objectPath = context.getPath(),
|
||||
ids = objectPath.map(function (domainObject) {
|
||||
return domainObject.getId();
|
||||
}),
|
||||
priorRoute = $route.current,
|
||||
// Act as if params HADN'T changed to avoid page reload
|
||||
unlisten = $scope.$on('$locationChangeSuccess', function () {
|
||||
$route.current = priorRoute;
|
||||
unlisten();
|
||||
});
|
||||
|
||||
$location.path("/browse/" + ids.slice(1).join("/"));
|
||||
|
Loading…
Reference in New Issue
Block a user