Getting the URL entered in browser before redirection in AngularJS?

978 views Asked by At

I'm trying to get the params of the URL originally entered in the browser. But angular "redirects" me automatically to '/'

For example, I enter this URL : http://localhost:9080/#/test?param1=en&param2=55

But I end up getting : http://localhost:9080/#/

var config = function (AppConfig, $urlRouterProvider) {
    'ngInject';

    $httpProvider.interceptors.push(function ($q, $location) {
        return {
            'request': function (config) {
                var params = $location.search(); //here : $location is already returning the wrong URL : http://localhost:9080/#/
                return config;
            }

        }
    });

};

Here is my only route :

$stateProvider.state('test', {
        url: '/',
        views: {
            'testView@' : {
                templateUrl: '/app/test/test.html',
                controller: 'test.controller',
                controllerAs: 'testVM'
            }
        }
    });

Why is that ? Is there a way to get the original URL ?

1

There are 1 answers

0
Anil Samal On BEST ANSWER

Use:

document.URL;

Or

window.location.href