0

Ok so basically I have the scenario where a service is very similar except for some initialization variables, which is the perfect candidate for factory.

However, I can't figure out how to use multiple services in the same component/module where each service has been initialized with a different factory?

Thanks in advance.

Ahmed-Anas
  • 5,471
  • 9
  • 50
  • 72

1 Answers1

-1

Service in angular 2 is a class, So you can easily do something like

let firstServiceInstance = new myServiceClass(...some arguments);
let secondServiceInstance = new myServiceClass(...some arguments);
let thiredServiceInstance = new myServiceClass(...some arguments);

And every of the above variables will hold reference to the service.

Gili Yaniv
  • 3,073
  • 2
  • 19
  • 34