首页 > 解决方案 > 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

标签: angular

解决方案


推荐阅读