在各自的模块角度 8 中声明组件后出现错误
Posted
技术标签:
【中文标题】在各自的模块角度 8 中声明组件后出现错误【英文标题】:Getting Error after declaring component in respective Module angular 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.
请让我知道我在这里做错了什么
【问题讨论】:
【参考方案1】:你也需要在声明下添加它
declarations: [StudyDetailsComponent, BasicInformationComponent, MaintenanceComponent, ProcedureCostComponent, CountryListComponent, StudyListComponent, MatchSiteComponent, DialogCTMSComponent ],
【讨论】:
嗨@Sajeetharan 感谢您的及时回答我已经创建了其他组件,当时没有发生此错误,为什么现在请告诉我 所有组件都应在模块内声明。如果您使用cli创建,它将自动添加到声明中 这是正确的,我用 CLi 创建只需要添加入口组件,因为如果我被删除 entryComponent 我得到错误这不是在入口组件中添加请告诉我原因 你需要了解***.com/questions/39756192/… 如果可能的话,您能否为我的问题提供支持投票,谢谢以上是关于在各自的模块角度 8 中声明组件后出现错误的主要内容,如果未能解决你的问题,请参考以下文章
在角度 CLI 中出现构建错误:无法重新声明块范围变量“ngDevMode”
错误:找不到模块'@ckeditor/ckeditor5-build-classic'角度9的声明文件