angular - Angular 导入子模块导致父模块的组件损坏
问题描述
我有一个carModule
包含两个组件car
和 car-detail
. 我需要使用从组件中调用的另一个模块命名的wheel
另一个组件。wheelModule
car-detail
我正在导出wheelComponent
inwheel.module.ts
然后添加wheelModule
到car.module.ts
文件中(在 的imports
部分中@NgModule
)。
现在我可以访问wheel
's 的组件 HTML tag( <wheelDetail></wheelDetail>
)car-detail.component.html
并且它工作正常。
问题是现在,调用的主要car
组件被car.component.html
破坏并显示wheel
组件的内容而不是car
组件的内容!!!
/vehicle/car/
:
car-detail.component.html
car-detail.component.ts
car.component.html
car.component.ts
car.modules.ts
/vehicle/wheel/
:
wheel.component.html
wheel.component.ts
wheel.modules.ts
关于如何解决它的任何想法?
wheel.module.ts
:
@NgModule({
declarations: [
wheelComponent
],
imports: [
...,
DxPopupModule,
...
],
exports: [
wheelComponent
]
})
car.module.ts
:
@NgModule({
declarations: [
carComponent,
carDetailComponent
],
imports: [
...,
wheelModule,
]
})
解决方案
推荐阅读
- java - DynamoDB:将 putItem 与空字符串一起使用失败
- c# - 从一张图像到位图的 Blit 像素,无需缩放
- c# - 在托管服务中注入类型化的 HTTP 客户端会创建强制依赖吗?
- javascript - 在 React 中创建一个包含可滚动行和可点击元素的表格
- python - 使用 python 进行面向对象编程中的简单原型设计与计划设计
- python - 使用 Azure Functions 请求和响应 JSON 格式的数据
- python - 如何在没有装饰器的情况下使异常处理代码可重用?
- android - 图片已上传到 Firebase 存储,但在应用 UI 中不可见
- android - 如何在 Expo React-Native 中使用下拉列表?
- python - sshtunnel 键盘交互