I am pretty new to Angular. I see there is a thing called $injector
whose function, get
, I can use to get a specific service. For example:
app.factory('$myService', function($injector) {
return { ...
var http = $injector.get('$http');
....
}
}
I will get the $http
service of Angular to the variable http
.
In other examples I see something like
app.factory('$myService', function($http) {
return {...}
This also inject the $http
service into the factory.
Is there a difference between the two? When should I use this or that?
Thank You!