Hi, Below example might help you.
Create a service named sharedVariable.ts
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root',
})
export class sharedVariableService {
sharedUserName: String = "" //set default value here.
constructor() { }
getSharedUserName(){
return sharedUserName;
}
setSharedUserName(string name){
sharedUserName = name;
}
}
Now in you component from where your popping the navigation. Import sharedVariableService in constructor.
constructor(sharedVariable : sharedVariableService ) { }
Before you create pop from navigation stack, just call the method setSharedUserName and pass value of your choice. And use the updated value from getSharedUserName function in the component of your choice.
Revert if you still have further doubts.