我有一个角度2应用程序,用角度2 beta 14编写。我正在升级到rc5。我使用的是最新的路由器,我的包json包含"@angular/router": "3.0.0-rc.1"
以前的路线配置如下:
{path:'/...',name:'LoggedIn',component:LoggedInComponent},
{path:'/auth', name:'Auth', component:AuthComponent}
现在我正在这样做
import { RouterModule , Routes } from '@angular/router';
import {AuthComponent} from "./auth/auth.component";
import {LoggedInComponent} from "./auth/logged-in.component";
import {LOGGED_IN_ROUTES} from "./auth/logged-in.routes";
const APP_ROUTES : Routes = [
{ path : '/...' , name :'LoggedIn' , component : LoggedInComponent , children : LOGGED_IN_ROUTES},
{ path : '' , component : AuthComponent},
{ path : 'auth' , component : AuthComponent},
];
export const routing = RouterModule.forRoot(APP_ROUTES);
我收到错误
Type '({ path: string; name: string; component: typeof LoggedInComponent; children: Route[]; } | { path...' is not assignable to type 'Route[]'.
Type '{ path: string; name: string; component: typeof LoggedInComponent; children: Route[]; } | { path:...' is not assignable to type 'Route'.
Type '{ path: string; name: string; component: typeof LoggedInComponent; children: Route[]; }' is not assignable to type 'Route'.
Object literal may only specify known properties, and 'name' does not exist in type 'Route'.
答案 0 :(得分:1)
答案 1 :(得分:0)
通过数据键将其作为数据传递,如下所示:
{ path: 'your_path', component: yourComponent, data: { name: 'your_path_name' }}