0

I have 2 applications from one to another I'm redirecting using window.location.href and passing the query parameter from 1st application. (Shown below in screenshot) from app1

In the 2nd application, I'm trying to access the query parameter using the activaedRoute. (like shown below): from app2

Im unable to get the query parameter in the 2nd application. What wrong am i doing here. 'name' is showing as null in the 2nd app. Please help...!!

Ashwini B
  • 23
  • 8
  • Is there a particular reason you are setting `window.location.href` instead of using angular's router `.navigate` function? – Fabian Strathaus Nov 03 '22 at 10:26
  • No... I tried with router.navigatebyUrl first and I was not successful. So tried like this. Should I be trying with the angular router.navigate itself? Im getting the error if I use the router.navigate : It says **cannot match any routes** – Ashwini B Nov 03 '22 at 11:57
  • Nevermind, I didn't notice that you were switching applications. Are you really sure, that it is logged `name in auth null`? Because my assumption is that the subscribe function is not triggered at all. If it is, can you ensure that the queryParam is available in your browser's URL? – Fabian Strathaus Nov 03 '22 at 12:16
  • Yes.Its printing the `name in auth` as null on the console. I am getting `name` in the browser's URL. I can see its passing. However, while trying to get the query parameter in the 2nd app it is showing the name value as **null**. I have even tried to debug with the name passing in the URL and its the same that time also. – Ashwini B Nov 03 '22 at 12:32
  • Sorry, but i am not able to reproduce this issue. Can you maybe provide a short screen recording? – Fabian Strathaus Nov 03 '22 at 14:12
  • Would this help: I'm trying to access the query parameter in the auth service( Inside canAccess method the first thing). When the route hits it first goes to auth service and tries to pull the query parameter from the URL. – Ashwini B Nov 04 '22 at 04:30
  • Are you talking about a `canActivate` guard? Or why do you think if the route hits, it first goes to auth service? You should definitely add the code you talk about to your question (formatted as code, not as an image). – Fabian Strathaus Nov 04 '22 at 06:34

0 Answers0