Reputation: 29
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:
GET Data code from event:
Upvotes: 0
Views: 270
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