Adjust the phase of the corner

AngularJS Inititalization

What happens in the configuration phase when the angular application loads. Impossible to imagine it. Now I am confused with providers. SO may be understandable for setting the phase, help me understand the whole process. How a provider can be entered in the configuration phase.

Thanks.

+8
angularjs bootstrapping
source share
1 answer

The angular app uses services ( $http , $location , etc.).

It is sometimes necessary to configure these services before using them. For example, the $location service has two execution modes: "normal" mode and "html5" mode. $http may need to configure some headers even if it sends its first HTTP request.

Angular uses providers to configure these services. Providers are objects whose role is to accept configuration parameters at the configuration stage, and then, when everything is configured, create a unique instance of the service.

So, to set up the $location service, you use its $locationProvider during the configuration phase. After this phase is completed, Angular, at the start-up phase, will call the provider method $get() , which will create and return the $location service (hence the name "provider").

+10
source share

All Articles