具有多个模块(如JHipster)的项目中的嵌套角度组件 [英] Nested angular components in projects with multiple modules like JHipster
问题描述
我正试图在另一个实体组件中显示一个实体组件.
I'm trying to show an entity component in another Entity component.
I found some information about shared modules online, I also checked this post but it's still not working for me.
推荐答案
好吧,当您的项目中有多个模块时,它会变得有些复杂.在由JHipster生成的项目中,该项目中有多个模块.
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:
假设应该在另一个组件内显示的实体组件是 ReviewComponent ,并且还假设所有与Review相关的组件都有一个review.module,则应在review.module中导出ReviewComponent:
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:...
我们假设应该在其中显示ReviewComponent的组件是 BusinessComponent ,并且有一个Business.module用于与业务相关的组件.您应该将Review模块导入其中:
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: [...
那么您可以在任何与业务相关的html组件中使用选择器
Then you’ll be fine to use the selector in any Business-related html component
这篇关于具有多个模块(如JHipster)的项目中的嵌套角度组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!