Which type of folder structure should be used with Angular 2?

后端 未结 9 1673
慢半拍i
慢半拍i 2021-01-29 18:45

I am an Angular 1 developer that is starting to learn about Angular 2. There are a lot of different types of folder structure methods depending on the training material. I am

9条回答
  •  生来不讨喜
    2021-01-29 19:30

    I’ve been using ng cli lately, and it was really tough to find a good way to structure my code.

    The most efficient one I've seen so far comes from mrholek repository (https://github.com/mrholek/CoreUI-Angular).

    This folder structure allows you to keep your root project clean and structure your components, it avoids redundant (sometimes useless) naming convention of the official Style Guide.

    Also it’s, this structure is useful to group import when it’s needed and avoid having 30 lines of import for a single file.

    src
    |
    |___ app
    |
    |   |___ components/shared
    |   |   |___ header
    |   |
    |   |___ containers/layout
    |   |   |___ layout1
    |   |
    |   |___ directives
    |   |   |___ sidebar
    |   |
    |   |___ services
    |   |   |___ *user.service.ts* 
    |   | 
    |   |___ guards
    |   |   |___ *auth.guard.ts* 
    |   |
    |   |___ views
    |   |   |___ about  
    |   |
    |   |___ *app.component.ts*
    |   |
    |   |___ *app.module.ts*
    |   |
    |   |___ *app.routing.ts*
    |
    |___ assets
    |
    |___ environments
    |
    |___ img
    |   
    |___ scss
    |
    |___ *index.html*
    |
    |___ *main.ts*
    

提交回复
热议问题