Reputation: 83
There's a button in a page that will redirect to my website, how should I get the page url that redirects to my website in angularjs since we don't have access to the page redirecting
$rootScope.$on('$locationChangeStart', function(evt:any, absNewUrl:any, absOldUrl:any):void {
console.log('prev path: ' + absOldUrl);
});
using this is giving us the current page.
ex: (testingPage.html should redirect to myPage.html how to get testingPage.html url)
Upvotes: 1
Views: 8132
Reputation: 421
The page should hit your website with a query string.
example.com
should redirect you to yoursite.com/?ref=example.com
, then you would be able to extract the query variable from $location.search();
in the form of {'ref': 'example.com'}
.
You can read more about $location
here: https://docs.angularjs.org/api/ng/service/$location
Upvotes: 1
Reputation: 943
Have you tried the window.location
object? Like location.href
. You also have the $location
object in Angular. doc
And then pass it as a parameter in the redirect url like myPage.html?referrer=...
Upvotes: 0