I have a service:
(angular
.module('app.services', ['ngResource'])
.factory('MyService', [
/******/ '$resource',
function ($resource) {
return $resource('myurl');
}
])
);
I need to create an instance of it in my code. I know that angular can inject it if I list it as one of the parameters, but I am not asking about that. I need to create an instance of it "manually". How is it done?
EDIT:
this is related to my other question: a controller and its dependencies in a template
basically, I have a generic controller that takes a service as a parameter, and I need to create this controller manually using $controller
object (to be able to use it in my template - please see the referenced question), and I need to supply a service object to it. My service needs an integer as a parameter, so I need to instantiate the service and set this integer on it as a property. Otherwise of course I would have just given the name of the service as a string to the $controller
.
See if $injector suits your needs.