I have List and Details components in an Angular (v7) project and I open the Details of a record using the following approach:
ListComponent.html:
<a routerLink="/details/" [state]="{ id: row.Id }">{{ row.Title }}</a>
DetailsComponent.ts:
import { Router, ActivatedRoute } from '@angular/router';
export class DetailsComponent {
constructor(private router: Router,
public activatedRoute: ActivatedRoute {
super();
this.id = this.router.getCurrentNavigation().extras.state.id; //get id parameter
}
}
I have encountered 2 issues to be fixed:
1) I need to stay on the same Details page on page refresh.
2) I want to open Details page for a record using a button click e.g. appending id parameter to the address of the Details page.
Is it possible to fix these 2 issues in a smart way in Angular 7?