我已經習慣了Angular 2,但我有幾個關於app.module.ts文件的問題。app.module.ts文件提供什麼服務?我應該在裏面做些什麼?
- 爲什麼我必須做進口這個文件,因爲我會在app.components.ts文件再次做 的輸入。
例如:我 導入我的自定義管道,然後我又不得不進口在我 app.components.ts文件
import { FirstPipePipe } from './first-pipe.pipe';
@NgModule({
declarations: [
AppComponent,
SecondComponent,
ThirdComponent,
FirstComponent,
FirstPipePipe
],
imports: [
BrowserModule, RouterModule.forRoot(appRoutes), HttpModule
],
providers: [FetchDataService],
bootstrap: [AppComponent] })
然後我有
imports: [
BrowserModule, RouterModule.forRoot(appRoutes), HttpModule
],
爲什麼我要導入一些類而其他類不是?
爲什麼這裏的供應商,因爲他們再一次出現在app.component.ts
providers: [FetchDataService]
基本上,我有我的app.component.ts文件重寫一切。
app.module.ts的用途是什麼?
讀[避免常見的混亂與角模塊(https://blog.angularindepth.com/避免 - 常見的混淆與模塊在角 - ada070e6891f) –
我有一個YouTube視頻,這裏解釋這個:https://www.youtube.com/watch?v=ntJ-P-Cvo7o – DeborahK
@DeborahK tnx視頻。 – masterach