【发布时间】:2016-09-24 13:47:20
【问题描述】:
我对 angular2 中的路线有疑问。今天我用的是和angular2官方教程一样的例子。 代码是这样的(file link):
// 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);
我的问题是。如果我有多个 crud,我会得到一堆组件(例如实体/列表、实体/添加、实体/编辑、实体/显示)
那么,如何解决这个问题?在不创建混乱组件的情况下组织路线的最佳方法是什么?
【问题讨论】:
标签: angular angular2-routing angular2-template angular2-directives