I'm integrating a small existing Angular JS app made by someone else into an exiting website that was not built with Angular.
All the Angular JS app files are kept in a completely separate directory and then the user can click on a link to take them to the index of that sub directory. For example:
<a href="/path/to/angular-app/?returnUrl=/original/location">Login.</a>
As you can see above, I need to pass a URL parameter called returnUrl
. I then need to pick up this value in the Angular JS app, using:
$location.search()
However, this actually returns an empty object. I think it's because the Angular JS is appending #!/login
on the URL after the URL parameter, like so:
example.com/path/to/app?returnUrl=/original/location/#!/login
If I modify the URL in the browser, moving the returnUrl
parameter to the end of the URL and refresh the page, it works and $location.search()
returns {returnUrl: "/original/location/"}
. However, as far as I can see I'm not able to change this in my website because the parameter is part of the link to the Angular JS app and #!/login
is added afterwards automatically.
I'm new AngularJS, so please explain as clearly as you can:
- What is going on here? And why is the URL parameter before the
#!/login
? - Why does this prevent
$location.search()
from returning anything? If I move the param to the end of the resulting URL, it works. - What can I do to fix this?