2

I am trying to pass the state property with routerLink and open it on a new tab. This is my code:

<a [routerLink]="['/caminho/item']" target='_blank' [state]="{carTO: carTO}">

Without target='_blank' I can get the state value this way:

router.getCurrentNavigation().extras.state.carTO

But when I use target='_blank', the state is undefined.

What do I need to do to be able to get the state, using routerlink and opening on a new tab(target='_blank')?

Scandiuzzi
  • 75
  • 1
  • 7
  • I personally stay away from routerStates. When you arrive on a page through a routerState, and press F5, the data is gone anyway. Can't you temporarily store the data in js session storage or some equivalent? (localStorage encode in the query string, database, ...) – Pieterjan Sep 10 '20 at 20:44
  • I am thinking about localStorage, but I was trying this approach first. – Scandiuzzi Sep 10 '20 at 20:48

0 Answers0