My question is an extension of asked question link is given below
can't get service instance from $injector.get()
var app = angular.module('myDI', []);
app.config(function($provide){
$provide.provider('greeting',function(){
this.$get = function(){
return function(name) {
console.log("Hello, " + name);
};
};
});
});
we can get Service instance using below code.
var injector = angular.injector(['myDI', 'ng']); //Add this line
var greeting = injector.get('greeting');
greeting('Ford Prefect');
var injector = angular.injector();
But if I add dependencies in Service like...
var app = angular.module('myDI', []);
app.config(function($provide){
$provide.provider('greeting',['$http','$q' function($http,$q){
this.$get = function(){
return function(name) {
console.log("Hello, " + name);
};
};
});
});
how we will get an instance of service using the angular injector.
Thanks a lot.