1
我對angular2中的路由有疑問。今天,我正在使用與angular2官方教程相同的示例。 的代碼是這樣的(file link):在angular2中組織路由的最佳方式
// app.routing.ts
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DashboardComponent } from './dashboard.component';
import { HeroesComponent } from './heroes.component';
import { HeroDetailComponent } from './hero-detail.component';
const appRoutes: Routes = [
{
path: '',
redirectTo: '/dashboard',
pathMatch: 'full'
},
{
path: 'dashboard',
component: DashboardComponent
},
{
path: 'detail/:id',
component: HeroDetailComponent
},
{
path: 'heroes',
component: HeroesComponent
}
];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
我的問題是。如果我有多個垃圾,我會得到一堆組件(如實體/列表,實體/添加,實體/編輯,實體/顯示)
那麼,該如何解決?組織我的路線而不創建凌亂組件的最佳方式是什麼?
這正是我所期待的! 我看到了這個結構,這是解決這個部分: https://angular.io/docs/ts/latest/guide/router.html#the-heroes-app-code 非常感謝! –