2017-05-26 5 views
1

Angular2でシンプルなルーティングを作成しようとすると: CでAngular2 - エラールーティング - タイプ 'の文字列は' 'タイプ<any>' を入力する割り当てられない

ERROR:/プロジェクト/ゲーミフィケーション/ srcに/アプリ/アプリを。 routing.ts(8,7):以下のように

Type '({ path: string; redirectTo: string; pathMatch: string; } | 
{ path: string; component: string; })[]' 
is not assignable to type 'Route[]'. 

Type '{ path: string; redirectTo: string; pathMatch: string; } | 

{ path: string; component: string; }' is not assignable to type 'Route'. 
Type '{ path: string; component: string; }' is not assignable to type 'Route'. 
    Types of property 'component' are incompatible. 
    Type 'string' is not assignable to type 'Type<any>' 

app.routing.ts:

const routes: Routes = [ 
{ path: '', redirectTo:'/login', pathMatch: 'full' }, 
{ path: 'explorer', component:'ExplorerQuizComponent' }, 
{ path:'login', component: 'LoginComponent'}]; 

@NgModule({imports: [ RouterModule.forRoot(routes) ], exports: [ RouterModule ]})` 

答えて

2

削除」、試してみてください:

const routes: Routes = [ 
{ path: '', redirectTo:'/login', pathMatch: 'full' }, 
{ path: 'explorer', component:ExplorerQuizComponent }, 
{ path:'login', component: LoginComponent}]; 
+0

ありがとうございました、@Wang Steven。それは今働く。 –

関連する問題