【问题标题】:How to create folder structure for modules in angular10如何为 Angular 10 中的模块创建文件夹结构
【发布时间】:2021-03-10 14:24:54
【问题描述】:

我有两个模块,比如教育和交通。我想为这些创建模块和组件。如何为这些创建完美的文件夹结构。如果有人知道请帮忙。

education
->school
   --> 1std component 
   --> 2std component
   --> 3std component
->college
   --> arts component
   --> engg component 
   --> diploma component 


transport
->cycle
   --> small component 
   --> medium component 
   --> large component 
->bike
   --> pulsar component 
   --> honda component 
   --> hundai component 

演示:https://stackblitz.com/edit/angular-ivy-atpxot?file=src%2Fapp%2Fapp.module.ts

【问题讨论】:

  • 您也可以投票赞成接受的答案:)

标签: angular8 angular9 angular10 angular11


【解决方案1】:

下面的文件夹结构可能对你有用!

-app
  
-shared
  -services
  -pipes
  -components
  -models

-modules
  -education
    -components
        -school
        -college
    -models
        -education.model.ts
    -services
        -education-service.ts

    -education.component.ts // this component should act like a container
    -education.component.html
    -education.component.module.ts        
    -education.component.route.ts

  -transport
    -components
        -cycle
        -bike
    -models
        transport.model.ts
    -services
        transport.service.ts
        
    -transport.component.ts // this component should act like a container
    -transport.component.html
    -transport.component.module.ts        
    -transport.component.route.ts

-app.component.ts
-app.component.html
-app.module.ts
-app-routing.module.ts

上面的文件夹结构提供了一种微服务架构,其中每个模块都有自己的服务/依赖项。

【讨论】:

  • 感谢您的回答。如何通过angular cli命令生成这些模块和组件?
  • “shared>services”和“education->services ->education-service.ts”有什么区别?
  • 可能会遵循您可以按顺序运行的命令 ng g m modules/education/educationng g c modules/education/components/school 等等。
  • 共享文件夹在这里是可选的,它的内容被假定为一般。而education/transport文件夹的内容是根据给定的相应文件夹具体的
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多