I read a router param in my MainComponent in this way:
ngOnInit(){
this.activatedRoute.params.subscribe(params => {
const id = params['id'];
console.log(id);
});
}
I need to read "id" in another component (ContactComponent) that is no related to MainComponent, here's my routing:
const routes: Routes = [
{ path: 'contatti', component: ContattiComponent },
{ path: 'main/:id', component: MainComponent}
];
my idea was to store "id" in a global variable and then read in ContactComponent that global variable. I have no idea on how to do so.