Reputation: 11661
Why Angular have services in dependency injection idea?
I know what is dependency injection is. but why not just create a ts file with import and export (which are singleton by default).
Which cases the idea of create ts file didn't cover?
Upvotes: 0
Views: 34
Reputation: 71931
I believe the guide and cook book are already pretty self explanatory. Things you do not have with just ts:
forwardRef
Anyways, if you think you can just use simple ts imports to get what you need, you can of course use it. Angular is aimed to give an opinionated way on how to structure your application and code. This is particularly useful in an enterprise environment when you are working with multiple developers, so that somebody who is proficient with Angular can easily familiarize himself with the new source.
If you are just working alone, you are free to do what you want :)
Upvotes: 1