具有多个模块(如 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屋!