Angular 角度7保持';基于对象id的';重定向后从URL

Angular 角度7保持';基于对象id的';重定向后从URL,angular,angular-router,cesium,Angular,Angular Router,Cesium,作为一个持续的过程 作为向上回答的建议, 我构建了一个服务,它保存了所有需要的参数,以便返回到与从特定URL导航之前相同的状态。 当我拥有一个按div id构建的对象(如铯/开放层/传单等)而不创建新的对象时,如何返回到相同的状态? 例如: 我通过给他div id和一些初始选项将他的查看器保存在服务中,当我从此页面导航时,我无法返回到该特定对象。 我能做什么 非常简短的示例代码: //app-routing.module const routes: Routes = [ { path:

作为一个持续的过程 作为向上回答的建议,
我构建了一个服务,它保存了所有需要的参数,以便返回到与从特定URL导航之前相同的状态。
当我拥有一个按div id构建的对象(如铯/开放层/传单等)而不创建新的对象时,如何返回到相同的状态?
例如:

我通过给他div id和一些初始选项将他的查看器保存在服务中,当我从此页面导航时,我无法返回到该特定对象。
我能做什么

非常简短的示例代码:

//app-routing.module  
const routes: Routes = [
  { path: '', redirectTo: 'main', pathMatch: 'full' },
  {path: 'main', component: MainPageComponent,  pathMatch: 'full'},
  {path: 'item', component: Items,  pathMatch: 'full'},
 ];
//MainPage TPL  
<div id="main-cesium"></div> 

//MainPageComponent   
ngAfterViewInit(){
    this.mainViewer = this.mainService.getMainCesium("main-cesium") 
    //check if already exist if yes return this object else build one
}

//MainService     
getMainCesiumViewer(mainCesiumId: string) {
    if(!this.mainCesiumViewer){
        this.mainCesiumViewer = new Cesium.Viewer(mainCesiumId,someConfigObj);
    }
    return this.mainCesiumViewer;
 }


//navigate to item  
this.router.navigate([ '/item']);

//mavigate to main  
this.router.navigate([ '/main']);
//app-routing.module
常数路由:路由=[
{路径:'',重定向到:'main',路径匹配:'full'},
{path:'main',component:MainPageComponent,pathMatch:'full'},
{路径:'item',组件:Items,路径匹配:'full'},
];
//主页第三方物流
//主页组件
ngAfterViewInit(){
this.mainViewer=this.mainService.getMainCesium(“主铯”)
//检查是否已经存在如果是返回此对象否则生成一个
}
//主要服务
getMainCesiumViewer(mainCesiumId:string){
如果(!this.mainCesiumViewer){
this.mainCesiumViewer=新的铯查看器(mainCesiumId,someConfigObj);
}
返回此.mainCesiumViewer;
}
//导航到项目
this.router.navigate(['/item']);
//马维吉特到梅因
this.router.navigate(['/main']);

请提供一些代码来帮助解释您的问题我试图只发送相关代码,如果仍然缺少此代码,我将提供更多@TomMettam