← BYTES
AngularJS·Intermediate·Ref: 5.2.2

How does AngularJS actually resolve a dependency like $scope or a custom service name when injecting it into a controller?

Have a question about this video? Mention reference 5.2.2 when you contact us.

a.It guesses based on variable name alphabetical order
b.It always creates a brand new instance from scratch every single time, even for singleton services
c.It matches the string name of the parameter against names registered with the injector (services, values, the built-in $-prefixed services, etc.) and supplies the corresponding instance
d.Dependency names must be passed as explicit strings in every single function call, with no parameter-name matching at all
The injector keeps a registry of every provider/service/value/constant that's been registered under a name; when a function requests a dependency, AngularJS looks that name up (by parsing the function's parameter names, or via an explicit $inject array) and passes in the found instance.

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES522#AngularJS