我正在使用角度7中的命名路由器插座,并且相应的组件正在渲染,请参见下面的代码。
this.router.navigate(['./globalassetmanager/main/assets/assetfamilies'], { queryParamsHandling: "merge" }).then((value) => {
if (value) {
this.router.navigate(['./globalassetmanager/main/assets/assetfamilies'],
{ queryParams: { page: "types", id: this.params.id, name: this.params.name, assetid: data } });
}
});
但是当我刷新时,组件无法正确渲染。我的意思是其他一些组件正在渲染。 请让我知道如何解决它。
请参见下面的routing.ts文件
const routes: Routes = [
{ path: '', redirectTo: 'side', pathMatch: 'prefix', outlet: 'innersidemenu', },
{ path: '', redirectTo: 'main', pathMatch: 'prefix', },
{
path: 'main', component: GlobalAssetManagementComponent,
children: [
{ path: '', redirectTo: 'assets', pathMatch: 'full' },
{
path: 'assets',
component: GlobalAssetManagementPageContentComponent,
children: [
{ path: '', redirectTo: 'views', pathMatch: 'prefix', },
{ path: 'views', component: GlobalAssetViewsComponent},
{ path: 'assetfamilies', component: AssetFamiliesComponent},
]
},
]
},
{
path: 'side', component: GlobalAssetManagementSidemenuComponent, outlet: 'innersidemenu',
children: [
// { path: '', outlet: 'cntsidemenu', component: AssetManagementComponent },
// { path: '', component: AssetManagementComponent },
{ path: '', redirectTo: 'assets', pathMatch: 'prefix', },
{ path: 'assets', component: GlobalAssetManagementSidemenuComponent },
// { path: 'families', component: AssetFamiliesSidemenuComponent}
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class GlobalAssetManagementRoutingModule { }
下面是初始路线
http://localhost:4200/blm/globalassetmanager/(main/assets/views//innersidemenu:side/assets)?page=libraries&id=118&name=Test%20Library
下面是第二条路线(使用事件导航到下面的路线)
http://localhost:4200/blm/globalassetmanager/(main/assets/assetfamilies//innersidemenu:side/assets)?page=types&id=118&name=Test%20Library&assetid=23f1506c-606d-440b-a777-14dc5d8bea70
如果我在路线上方刷新,则更新如下
http://localhost:4200/blm/globalassetmanager/(main/assets/assetfamilies//innersidemenu:side/assets)?page=libraries&id=118&name=Test%20Library