【问题标题】:Getting Error after declaring component in respective Module angular 8在各自的模块角度 8 中声明组件后出现错误
【发布时间】:2020-05-12 01:26:45
【问题描述】:

在模块中声明组件名称后,出现以下错误

这是我的学习详细信息模块,其中包含我在此处映射的所有相关组件

    import { NgModule } from '@angular/core';
    import { CommonModule } from '@angular/common';
    import { StudyDetailsComponent } from './study-details.component';
    import { RouterModule } from '@angular/router';

    import { PartialsModule } from '../../partials/partials.module';
    import { CoreModule } from '../../../core/core.module';

    /* material components */
    import { MaterialModule } from '../../../shared/modules/material.module';
    /* import componenets for study details */
    import { BasicInformationComponent } from './basic-information/basic-information.component';
    import { MaintenanceComponent } from './maintenance/maintenance.component';
    import { ProcedureCostComponent } from './maintenance/procedure-cost/procedure-cost.component';
    import { CountryListComponent } from './maintenance/procedure-cost/country-list/country-list.component';
    import { StudyListComponent } from './maintenance/procedure-cost/country-list/study-list/study-list.component';
    import { MatchSiteComponent } from './match-site/match-site.component';
    import { FormsModule } from '@angular/forms';
    import { NgxFlagPickerModule } from 'ngx-flag-picker';
    import { DialogCTMSComponent } from './match-site/dialog-ctms/dialog-ctms.component';
    import { MatDialogModule } from '@angular/material';
    //import { DialogCTMSComponent } from '../study-details/match-site/dialog-ctms/dialog-ctms.component';



    @NgModule({
      declarations: [StudyDetailsComponent, BasicInformationComponent, MaintenanceComponent, ProcedureCostComponent, CountryListComponent, StudyListComponent, MatchSiteComponent ],
      imports: [PartialsModule, MaterialModule,MatDialogModule,
        CoreModule,FormsModule,NgxFlagPickerModule,

        CommonModule, RouterModule.forChild([
          {
            path: '',
            component: StudyDetailsComponent
          },
        ])
      ],

      entryComponents: [
        DialogCTMSComponent
      ],

这是我遇到的错误

Error: Uncaught (in promise): Error: Component DialogCTMSComponent is not part of any NgModule or the 
module has not been imported into your module. Error: Component DialogCTMSComponent is not part of 
any NgModule or the module has not been imported into your module.

请让我知道我在这里做错了什么

【问题讨论】:

    标签: angular angular8


    【解决方案1】:

    你也需要在声明下添加它

     declarations: [StudyDetailsComponent, BasicInformationComponent, MaintenanceComponent, ProcedureCostComponent, CountryListComponent, StudyListComponent, MatchSiteComponent, DialogCTMSComponent ],
    

    【讨论】:

    • 嗨@Sajeetharan 感谢您的及时回答我已经创建了其他组件,当时没有发生此错误,为什么现在请告诉我
    • 所有组件都应在模块内声明。如果您使用cli创建,它将自动添加到声明中
    • 这是正确的,我用 CLi 创建只需要添加入口组件,因为如果我被删除 entryComponent 我得到错误这不是在入口组件中添加请告诉我原因
    • 如果可能的话,您能否为我的问题提供支持投票,谢谢
    猜你喜欢
    • 2018-05-15
    • 2016-10-14
    • 1970-01-01
    • 1970-01-01
    • 2021-11-10
    • 2018-01-28
    • 2013-08-21
    • 2020-10-22
    • 1970-01-01
    相关资源
    最近更新 更多