2
I was passing the parameter Id
using Routes
:
const routes: Routes = [
{ path: '', redirectTo: 'sites', pathMatch: 'full' },
{ path: 'addSite', component: AddSiteComponent },
{ path: 'sites', component: ShowSitesComponent },
{ path: 'sites/editSite/:_id', component: EditSiteComponent }
];
That when passing the parameter site._id
, it supposedly goes to the component editSite
(I can see it in the URL) with this parameter, but I cannot receive the parameter value to use in the other component.
<button mat-raised-button color="primary">
<a routerLink="editSite/{{site._id}}" style="text-decoration: none; color: white" routerLinkActive="active">Editar</a>
</button>
What should I put on to receive this id
? or any other parameter.
i do so, in the init of the editing Component: if ( this.activatedRoute.snapshot.params && this.activatedRoute.snapshot.params.id ) { const id = this.activatedRoute.snapshot.params.id;}
– Isaías de Lima Coelho