我已经开始适应Angular 2,但对于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] })
< p > 然后我有 imports: [
BrowserModule, RouterModule.forRoot(appRoutes), HttpModule
],
为什么我要导入某些类,而有些不需要?
这里为什么需要提供者,因为它们再次出现在app.component.ts中。
providers: [FetchDataService]
基本上,我需要重写我的app.component.ts文件中的所有内容。
app.module.ts的目的是什么?