Add a subscription to your component (I guess, PlanificadorComponent
or similar), subscriping ActivatedRoute
:
private subscription: Subscription;
id: string;
constructor(private route: ActivatedRoute) {
}
ngOnInit(): void {
this.subscription = this.route.params.subscribe(params => {
this.id = params.id;
});
}
ngOnDestroy(): void {
if (this.subscription) {
this.subscription.unsubscribe();
}
}
See also Getting route information:
Often, as a user navigates your application, you want to pass
information from one component to another. For example, consider an
application that displays a shopping list of grocery items. Each item
in the list has a unique id. To edit an item, users click an Edit
button, which opens an EditGroceryItem component. You want that
component to retrieve the id for the grocery item so it can display
the right information to the user.
You can use a route to pass this type of information to your
application components. To do so, you use the ActivatedRoute
interface.
That seems to match your requirement. There is also a step by step guide provided.