Hey everyone, I am currently working on an Angular project where upon login, the back end API generates a JWT token that is then passed to the front end. After getting the JWT token, I decode it to extract some details in the login.component.ts file. Now, I want to pass this decoded data to my top-bar component. The challenge here is that the top-bar component has already been loaded in the application. Can anyone guide me on how to achieve this?
Using Angular 7 CLI
Login.component.ts
onSubmit(form:NgForm){
//some code here for login authentication----------------
const helper = new JwtHelperService();
const decoded= helper.decodeToken(result.token);
console.log(decoded);
}
Top-Bar.component.ts
ngOnInit() { }