Nested angular components in projects with multiple modules like JHipster

拈花ヽ惹草 提交于 2019-12-01 11:02:21

Well, it gets a little bit complicated when you have multiple modules in your project. In a project like the ones generated by JHipster there are several modules in the project.

But no worries, the solution is easy:

Assuming the entity component supposed to get displayed inside another component is ReviewComponent and also assuming there is a review.module for all the Review-related components, you should export ReviewComponent in review.module:

@NgModule({ 
imports: [ByubSharedModule, RouterModule.forChild(ENTITY_STATES)],
    exports: [
        ReviewComponent
    ],
    declarations:...

And let's say the component which is supposed to display ReviewComponent inside is BusinessComponent and there is a business.module for Business-related components. You should import the Review module into it:

@NgModule({
    imports: [ByubSharedModule, ByubReviewModule, RouterModule.forChild(ENTITY_STATES)],
    declarations: [...

Then you’ll be fine to use the selector in any Business-related html component

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!