Reputation: 4189
In my angular 4 application I need to go in the same page with different routing param, for example I have:
/ticketBundles/{id}
/ticketBundles/new
/ticketBundles/{id}/copy
Now when I am navigating I use this.router.navigate(path,id)
In 2 and 3 I need to go in the same page but in a different "mode", In third case I need to load some data so what is the best practice to do that?
Third path is a good path?
If I use a path like /ticketBundles/copy/{id}
I am following a good way?
Upvotes: 1
Views: 716
Reputation: 19660
It is recommended to follow RESTFUL programming. What exactly is RESTful programming?
So for example the closest you can get in your example would be..:
NEW (POST): /ticketBundle
UPDATE (PUT): /ticketBundle/{id}
SHOW (GET): /ticketBundle/{id}
and for your copy i would do /ticketBundle/{id}/copy
You should take a look at the official docs for angular routing to help you 1. Navigate to a new page. 2. Pass in the params. 3. Retrieve the params on a new page.
https://angular.io/guide/router
In your routing module:
{ path: 'ticketBundle/:id', component: ticketComponent }
In your component
this.router.navigate(['/ticketBundle', { id: ticketID}]);
Upvotes: 1