角度6:网址上显示的插座名称如何删除?

时间:2018-11-01 07:39:28

标签: javascript angular routing router-outlet

在网址上显示

路由器出口名称。 如何删除此链接,我在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>

0 个答案:

没有答案