特征模块中的Angular 2路径

时间:2017-05-26 23:08:33

标签: angular angular2-routing

我必须在主模块和功能模块中使用路由。 当我将路由器导入功能模块时,应用程序无法正常工作,浏览器正在“思考”并继续加载,直到chrome说“页面没有响应”。

我没有成功 this answer

应用路线:

<g>

和功能模块中的路线:

const appRoutes: Routes = [
        { path: 'login', component: AuthComponent },
        { path: 'register', component: RegisterComponent },
        { path: 'resetpassword', component: ResetPassword },
        { path: 'resetpassword/choose', component: ChoosePassword },
        { path: 'tournament', component: Tournament },
        { path: '', component: HomeComponent, pathMatch: 'full', canActivate: [AuthGuard] },

        { path: '**', redirectTo: '' }
    ];

    export const routing = RouterModule.forRoot(appRoutes);

在app.module中我导入功能模块和app.router:

const appRoutes: Routes = [
    {
        path: 'tournament', component: Tournament, children:
        [
            { path: 'new', component: TournamentCreationMain },
        ]
    },
    { path: '', component: Tournament, pathMatch: 'full', canActivate: [AuthGuard] },

    { path: '**', redirectTo: '' }
];

export const routingTournament = RouterModule.forChild(appRoutes);

在功能模块中我导入自己的路由器:

imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    TournamentModule,
    routing
]

提前致谢 最大

1 个答案:

答案 0 :(得分:1)

据我所知,您不必在appRoutes中为锦标赛路径定义锦标赛组件。您还应该在children数组中定义锦标赛的所有子路由。请尝试更改为:

dragon
相关问题