1

I want to display the smart table row data on another page. So whenever the user clicks on the row data its routes to the new page with this particular row data.

Please help on this, I am stuck

ThanksThis is mytable in advanced

1 Answers1

1

Looking at the ng2-smart-table documentation, it seems like there is a userRowSelect event that this table triggers when the user clicks a row. You can handle that and use the Router to redirect to another page.

You can pass the row data using the extras, something like this:

this.router.navigateByUrl('<path>', { state: data });

and you can access the passed data inside your component that handles the route by using the router again

const state = this.router.getCurrentNavigation()?.extras.state;

but please be aware that the router.getCurrentNavigation method only returns something if called in the constructor (or to be more precise: before the navigation has ended). If you need access to the state outside of the constructor, you can use history.state instead (but this adds another property to whatever data you pass, which is the navigationId).

Octavian Mărculescu
  • 4,312
  • 1
  • 16
  • 29