1

In my angular 4 application I have a page with a table and every row has 3 icon ( duplicate, edit, delete). when I click on the edit icon the application route to detail page for edit this particular object, whit this path:

 path: 'object/:code',
 loadChildren: '....

When I click on the duplicate icon I want to route to the same page like edit but I need to pass another information because I need to tell to the detail page that I am in duplicate mode So what is the best practice and how can I catch it after in the detail page

Derek Brown
  • 4,232
  • 4
  • 27
  • 44
Alessandro Celeghin
  • 4,039
  • 14
  • 49
  • 95
  • if i understand you correctly it sounds like you want to pass data when routing, check out this answer https://stackoverflow.com/questions/36835123/how-do-i-pass-data-in-angular-2-components-while-using-routing – omer Sep 26 '17 at 14:45

1 Answers1

0

From your question, I understand that you need to reach a route with a defined parameter representing an object identifier (your row I imagine), which is why you need a standard route parameter.

For your options, which are additionnal parameters for the same route, you might want to look at this link from the official documentation about QueryParams.

In the route parameters example, you only dealt with parameters specific to the route, but what if you wanted optional parameters available to all routes? This is where query parameters come into play.

This way you will be able to handle the standard route with an Id parameter, and add options for every use-case you want to manage.

Alex Beugnet
  • 4,003
  • 4
  • 23
  • 40