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 非常感谢! –