I'm creating a factory
service
which provides me couple function like
var myApp = angular.module('panelServices', ['ngResource']);
myApp.factory('myService', [...]{
function myService(){
this.list = [];
}
myService.prototype.method1: fn() {} ,
...
myService.prototype.methodn: fn() {},
return myService;
});
The I Inject myService
via DI into my controllers
and use new myService()
to instanciate a new instance of myService
.
I did not find another way to do this, I was thinking of "copying" the service
into e.g.: anotherService
(based on the fact that service
are singletons
).
My goal is to have a service
to use for different models
(they do not share data, only methods)-
Please tell me if I did not explain well, thanks in advance.