我的app.module e.ts中有以下内容:

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { HttpModule, Http } from '@angular/http';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { EliteApi } from '../shared/shared';
import { MyApp } from './app.component';
import { MyTeams, Tournaments, TeamDetails, Teams, TeamHome, Standings } from '../pages/pages';

import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

@NgModule({
    declarations: [
        MyApp,
        MyTeams,
        TeamDetails,
        Tournaments,
        Teams,
        TeamHome,
        Standings
    ],
    imports: [
        BrowserModule,
        IonicModule.forRoot(MyApp),
        HttpModule
    ],
    bootstrap: [IonicApp],
    entryComponents: [
        MyApp,
        MyTeams,
        TeamDetails,
        Tournaments,
        Teams,
        TeamHome,
        Standings
    ],
    providers: [
        HttpModule,
        StatusBar,
        SplashScreen,
        { provide: ErrorHandler, useClass: IonicErrorHandler },        
        EliteApi
    ]
})
export class AppModule { }

目前我的declarationsentryComponents都是一样的.它们包含我为应用程序构建的所有页面/组件.如果我从任何属性中删除任何条目,我会在angular2中得到错误.

我的问题是,如果它们总是相同的,那么这些属性需要什么?我想我肯定错过了一些要点.entryComponents和Declarations什么时候会不同?

推荐答案

entryComponents数组用于定义在html中找不到的only个组件,这些组件是用ComponentFactoryResolver动态创建的.Angular需要这个提示来找到它们并编译.所有其他组件都应该列在声明数组中.

Here's the documentation on angular site

Angular相关问答推荐

如何在Angular 17中使用Angular—calendum?

是否可以将Angular 路由配置为在点击带有本地人力资源S的锚点时更新Angular 路由?

MAT-复选框更改事件未在onSubscriberCheck函数中返回选中的值

我应该对我想要在我的Angular 17+组件中显示的任何变量使用信号吗?

使用指令的 Angular 自定义验证在 ng-change 中无法正常工作

无法在单个元素上多次监听同一个事件

ngrx 效果等到从初始值以外的其他状态收到响应

无法在 Angular 中使用 CryptoJS 正确加密

执行ng generate environments时出错时需要合集和原理图

模块内的命名路由出口 - 路径匹配但内容未加载

Summernote 文本区域的输入字段文本验证失败

TypeError:this.restoreDialogRef.afterClosed 不是函数

无法将项目从 Angular 13 更新到 14

在Angular 4中有条件地应用点击事件

如何修复 [Object: null prototype] { title: 'product' }

如何在两个模块之间共享服务 - @NgModule 在Angular 而不是在组件之间?

Angular 没有可用于依赖类型的模块工厂:ContextElementDependency

Angular2:如果 img src 无效,则显示占位符图像

将 Angular 5 升级到 6 时,我得到不兼容的对等依赖(使用 ng update @angular/core)

Angular 4 Bootstrap 下拉菜单需要 Popper.js