angular - Multi module angular
问题描述
I would like to build an architecture for my angular project, but modular and with each component with unique responsibility.
So, in each component I have, html, css, component, service, model, dto and module.
I have a lot of doubt about the part of the modules I'm creating, because sometimes, I have the following error.
Type CarComponent is part of the declarations of 2 modules: CarModule and ComponentsModule! Please consider moving CarComponent to a higher module that imports CarModule and ComponentsModule.
You can also create a new NgModule that exports and includes CarComponent then import that NgModule in CarModule and ComponentsModule.
----|app
----|---|components
----|---|-------|business
----|---|-------|-----|cars
----|---|-------|-----|-----|model
----|---|-------|-----|-----|-- car-model.ts
----|---|-------|-----|-----|-- car-dto.ts
----|---|-------|-----|-----|service
----|---|-------|-----|-----|-- car.service.ts
----|---|-------|-----|-- car.component.ts
----|---|-------|-----|-- car.html
----|---|-------|-----|-- car.css
----|---|-------|-----|-- car.module.ts import/export car.component.ts
----|---|-------| business.module.ts // import/export car.module.ts
----|---|-------|shared
----|---|-------|-----| menu
----|---|-------|-----|-----|model
----|---|-------|-----|-----|-- menu-model.ts
----|---|-------|-----|-----|-- menu-dto.ts
----|---|-------|-----|-----|service
----|---|-------|-----|-----|-- menu.service.ts
----|---|-------|-----|-- menu.component.ts
----|---|-------|-----|-- menu.html
----|---|-------|-----|-- menu.css
----|---|-------|-----|-- menu.module.ts
----|---| components.module.ts
----| app.module.ts
解决方案
推荐阅读
- c# - C# 检查字符串长度是否为 188,如果不是
- docker - 挂载卷 .NET Core Docker
- javascript - 如何添加和删除
- c++ - ASAN 显示 heap-use-after-free 而 boost::asio 在套接字上调用纯 recv
- spring-boot - 如何启用 IP 查找 - Spring MVC 中的 enableLookups
- uwp - Prism 7 UWP 导航返回参数丢失
- c# - 获得系列中每个角色的最高价值
- xamarin.forms - 缩放其中的内容时,网格的单元格尺寸不一致
- c# - 我可以在泛型方法中返回特定类型的任意值吗?
- ember.js - 在 ember 插件中覆盖文件