【发布时间】:2017-02-06 22:43:07
【问题描述】:
我正在开发一个依赖于angular 2 的Ionic 应用程序(2.0.0-rc0)。所以新引入了ngModules。我在下面添加我的app.module.ts.。
import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
import { Users } from '../pages/users/users';
@NgModule({
declarations: [
MyApp,
Users
],
imports: [
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
Users
]
})
export class AppModule {}
entryComponents 在这里做什么? Components 已在 declarations 中定义。那么重复它们有什么必要呢?如果我不在这里包含组件会怎样?
【问题讨论】:
-
Angular 使用 entryComponents 来启用“摇树”,即只编译项目中实际使用的组件,而不是编译
ngModule中的所有declared但从未使用过的组件。 angular.io/docs/ts/latest/cookbook/…入口组件-
标签: angular angular-components angular-module