I did a lot of research on this myself on the last day or two. I can share with you what I discovered and a few thoughts.
First of all, you can get some information about the current path and contexts as follows:
this.router.router.currentHandlerInfos
Returns an array. Each object has both a name and a context property. The names match the name of the router you are calling in transitionTo.
In my opinion, although you could work with something like that, it would be dirty. API docs are not relevant to this, and it may not be the intention to use this as a public API.
I see problems with the above solution for deeper nested dynamic segments. Given how new the v2 router is, I think it will continue to evolve, and the best solution is likely to come up. This is a fairly common thing that wants to keep the current location and return to it later.
In the meantime, instead of forwarding, is it possible to use a conditional block in the template that represents the login, and not the output, if the authentication flag is not set to ApplicationController? I know that this is not so "right", but it is "right now."
source share