Angular2: How to find out what was previous page url when using angular2 routing
I am developing an angular2 app and I use router.
I am in a page /myapp/signup. after signup I navigate the use to /myapp/login. /myapp/login can also be navigated from my home page which is /myapp. So now, when the user users /myapp/login I go back. This can be done by using location.back(). But I dont want to go back when the user is coming from /myapp/signup. So I should check if the user is coming from /myapp/signup and if so, I want to direct it to somewhere else.
How can I know the previous url so that I direct the user to a specific state based on that ?