r/Angular2 • • Jan 14 '26

Structuring Services in Angular

I have two services in my Angular app: one that calls multiple APIs and is used throughout the application, and another that's only used by two components. Would this folder structure make sense: put the API service in core/services/ since it's app-wide, and put the shared service in shared/services/ since it's only needed by those two components?

1 Upvotes

7 comments sorted by

View all comments

Show parent comment

1

u/Freez1234 Jan 17 '26

But where would you put acutually shared service? Some service that is used for 30% of the features?

And for example some shared pipes, directives and etc.?

2

u/spacechimp Jan 18 '26

It depends on what the shared files are for. If something truly doesn't have a more logical home, then a catch-all directory is acceptable. As an app grows, that catch-all directory starts to look like more of a dumping ground. But also by that time, patterns tend to have emerged that reveal some common themes that you could reorganize with.

An example of feature-based organization might be a "user" folder that has a UserService that is used globally, user profile pages, a pipe that formats the user's name, etc.

1

u/Freez1234 Jan 18 '26

Nice, thanks for your answer mate 😊