Shaniqwa
Shaniqwa

Reputation: 2074

Angular: Share service between modules with Rxjs

I have 2 different modules that need to share the same data, and keep updating as user make selections.

I'm using BehaviorSubject in a service to store the data, but the result i'm getting is this:

each module has it's own 'copy' of the service, each is storing it's own data. so selections made in module 1 exist there, and same for module 2. How can I truly share data across all angular app ?

Upvotes: 0

Views: 277

Answers (1)

asmmahmud
asmmahmud

Reputation: 5044

You can include your service class name in your root module ( ie AppModule) providers array.

@NgModule({ 
 providers: [YourServicee],........

export class AppModule { }

Upvotes: 2

Related Questions