3
試圖建立路由首次角2(路由器3.0.0)參數類型{路徑:串,組分HomeComponent} []是不能分配給參數類型路由
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule} from '@angular/router';
import { AppComponent } from './app.component';
import { BoardComponent } from './board/board.component';
import { HomeComponent } from './home/home.component';
@NgModule({
declarations: [
AppComponent,
BoardComponent,
HomeComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
RouterModule.forRoot([
{ path: '', component: HomeComponent }
])
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
我得到的上錯誤:
Argument type {path: string, component HomeComponent}[] is not assignable to parameter type Routes
不知道是怎麼回事就在這裏,因爲我下面的文檔幾乎到了一封信:https://angular.io/docs/ts/latest/guide/router.html。
編輯:home.component.ts
:
<p>Home works!</p>
請出示代碼'home.component.ts' –
請從'home.component.ts'添加所有的代碼。 'HomeComponent'應該是一個具有'@ Component'裝飾器的類 – yurzui