我正在使用Ionic
应用程序(2.0.0-rc0
),这取决于angular 2
。所以包括了ngModules
的新介绍。我在下面添加我的app.module.ts.
。angular ngModule中的entryComponents是什么?
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'中声明的组件,但从不使用。 https://angular.io/docs/ts/latest/cookbook/ngmodule-faq.html#!#why-does-angular-need-_entrycomponents_- – Samar