微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Angular 导入子模块导致父模块的组件损坏

如何解决Angular 导入子模块导致父模块的组件损坏

我有一个 carModule 包含两个组件 carcar-detail。我需要在 wheel 组件中使用另一个名为 wheelModule 的模块中的另一个名为 car-detail 的组件。

我正在导出 wheelComponent 中的 wheel.module.ts,然后在 wheelModule 文件添加 car.module.ts(在 imports@NgModule 部分).

现在我可以访问 wheel 中的 <wheelDetail></wheelDetail> 组件 HTML 标记 (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
      ],wheelModule,]
})

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。