Patricio Vargas
Patricio Vargas

Reputation: 5522

How to create a shared service to be used in multiple Angular apps?

Is it possible to create a shared service to be used in multiple Angular app? if yes, How?

For example the way we create a angular library and we can use it externally from our app if we put it in a npm package. Can we achieve the same but only with a service so multiple apps can consume it?

E.g I created service X

I have app A and app B

I want to inject via dependency injection service X in app A and B.

Upvotes: 0

Views: 1156

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222532

Simple direct answer is YES, you are looking for actually a library not a service.

The Angular Library Series - Creating a Library with the Angular CLI

It's very similar to how you publish your shared package to NPM but Angular CLI really made it super simple.

Upvotes: 3

Related Questions