I'm confused with the correct structure of my angular application. May i ask for advice for the correct Angular structure of my app? What is the correct structure according to the Angular docs? I'm confused. Thanks. Please see the 2 Angular structure on my image. Do i need to separate the services and models to a different folder?
Asked
Active
Viewed 5,912 times
3
-
See https://angular.io/guide/styleguide#application-structure-and-ngmodules. – jonrsharpe Jan 21 '19 at 12:21
-
@jonrsharpe. Yes i been through it. I just need some help. Thanks – Joseph Jan 21 '19 at 12:22
-
Possible duplicate of [Angular folder structure and component services](https://stackoverflow.com/questions/51779093/angular-folder-structure-and-component-services) – Krzysztof Raciniewski Jan 21 '19 at 12:24
-
Then what is unclear from it? Opinion-based questions like this are not a good fit from SO; it's up to you and your team to decide what's best for you. – jonrsharpe Jan 21 '19 at 12:24
-
Like @jonrsharpe mentioned there is a styleguide. Which shows one way of doing it . The most important thing about folder structure is being consistent and making sure your whole team does it the same. – Jelle Jan 21 '19 at 12:24
-
@jonrsharpe. I mean i just need clarification on whether to put services and models on a separate folder? – Joseph Jan 21 '19 at 12:26
-
It's up to you. If you want to know how the Angular team would recommend doing it, look at the example layout which answers that question. – jonrsharpe Jan 21 '19 at 12:27
-
@Jelle. Please don't vote the close. I really need help/advise from other developers too. Thank you – Joseph Jan 21 '19 at 12:30
-
@jonrsharpe. Please don't vote the close. I really need help/advise from other developers too. Thank you – Joseph Jan 21 '19 at 12:30
-
As above, SO doesn't offer advice on opinion-based matters. If that's what you want, you should seek it elsewhere. – jonrsharpe Jan 21 '19 at 12:31
1 Answers
2
No specific folder structure is "correct". If your application is small and you just have a few components and a single module, I would keep it simple in a flat structure. If there are lot's of modules and components, maybe group components and services in the same folder as the module where they are declared.
In any case the folder structure is not what makes your Angular app work or not, but you should make it in a way that navigating your source files is as easy and readable as possible.
Also see this: https://angular.io/guide/styleguide#flat

Peter Salomonsen
- 5,525
- 2
- 24
- 38
-
-
-
-
Yes - I prefer to have everything concerning users (including model and services) in the users folder, and branches in the branches folder. – Peter Salomonsen Jan 21 '19 at 12:36
-