路由器出口名称。 如何删除此链接,我在StackOverflow here上发现了相同的问题,但没有给出答案。所以我再次发布了在我的项目中 网址显示为:http://localhost:4200/dashboard/(dashboardSection:profile)
但我想使它像
http://localhost:4200/dashboard/profile
http://localhost:4200/dashboard/list
我已经提供了用于路由的所有代码。
app.module.ts
const appRoutes: Routes = [
{ path: 'home', component: HomeComponent},
{ path: 'sign-up', component: SignUpComponent, canActivate: [PreventLoggedInAccess] },
{ path: 'file', component: FileUploadComponent, canActivate: [AuthGuard] },
{ path: 'dashboard', component: DashboardComponent, canActivate: [AuthGuard],
children:[
{
path: "list",
component: ListingListComponent,
outlet: 'dashboardSection'
},
{
path: "profile",
component: ProfileEditComponent,
outlet: 'dashboardSection'
}
]
},
{ path: '',
redirectTo: 'home',
pathMatch: 'full'
},
{ path: '**', component: PageNotFoundComponent }
];
在导入部分@NgModule({});
RouterModule.forRoot(
appRoutes,
{ enableTracing: false } // <-- debugging purposes only
),
dashboard.component.html
<li [routerLink]="['/dashboard',{ outlets: { dashboardSection: ['list'] }}]" routerLinkActive="active">List</li>
<li [routerLink]="['/dashboard',{ outlets: { dashboardSection: ['profile'] } }]" routerLinkActive="active">profile</li>