The order of services, factories and suppliers in AngularJS?

Does AngularJS framework do all of the above in a predefined order or is it done by the programmer?

+2
source share
2 answers

In terms of terminology, factories can create services, and suppliers provide services to the components that request them. If some of your services depend on another service, then, of course, there must be some alternative performance of services and providers. Making sure all these things happen in the correct order to allow all services to be created is work on injecting Angular dependencies.

The question arises: why are you interested in what order do factory functions work in? If you correctly state your dependencies and your services are not properly connected, Angular should take care of you. The only exotic case you may encounter is a circular addiction, which you can see here here .

+3
source

Providers and constants are created during the configuration phase, and after the configuration phase, factories, services and values ​​are created (therefore you cannot insert them into the configuration).

There are no other minor differences in my knowledge (which means that you can accept all services), and by this I mean that any type of provider that you enter will be available to you)

+4
source

Source: https://habr.com/ru/post/1545511/


All Articles