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

后端 未结 9 1685
慢半拍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:09

    If project is small and will remain small, I would recommend to structure by type (Method 2: ng-book2)

    app
    |- components
    |  |- hero
    |  |- hero-list
    |  |- villain
    |  |- ...
    |- services
    |  |- hero.service.ts
    |  |- ...
    |- utils
    |- shared
    

    If project will grow you should structure your folders by domain (Method 3: mgechev/angular2-seed)

    app
    |- heroes
    |  |- hero
    |  |- hero-list
    |  |- hero.service.ts
    |- villains
    |  |- villain
    |  |- ...
    |- utils
    |- shared
    

    Better to Follow official docs.
    https://angular.io/guide/styleguide#application-structure-and-ngmodules

提交回复
热议问题