manish jadli
manish jadli

Reputation: 29

Data / token sharing issue from angular micro-frontend one project to another project

Hi i am stucking the data sharing/ token sharing in another project in angular standalone microfrontend. Please provide your suggestion. Data will be get it second times. not get initial time.

SEND Data code on click:

enter image description here

GET Data code from event:

enter image description here

Upvotes: 0

Views: 270

Answers (1)

Andrei
Andrei

Reputation: 12206

I would propose you to make a "shared" library for your shell and remote. this way things imported from shared would be one instance. For example you could make a user service to share users

// shared
class UserService {
  getToken(): string {return localStorage.getItem('loggedToken');}
}
// any place (shared or remote)
import {UserService} from '@shared';
...
token = inject(UserService).getToken();

ngOnInit() {
  console.log('token', this.token);
}

Upvotes: 0

Related Questions