2016-12-16 58 views
1

我正在尝试获取最初在浏览器中输入的网址的参数。但角 “重定向” 我自动'/'在AngularJS中重定向之前获取在浏览器中输入的URL?

例如,我进入这个网址:http://localhost:9080/#/test?param1=en&param2=55

但我最终得到: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; 
      } 

     } 
    }); 

}; 

这是我唯一的出路:

$stateProvider.state('test', { 
     url: '/', 
     views: { 
      '[email protected]' : { 
       templateUrl: '/app/test/test.html', 
       controller: 'test.controller', 
       controllerAs: 'testVM' 
      } 
     } 
    }); 

这是为什么?有没有办法获得原始网址?

+0

显示你的路由定义 – Ladmerc

回答

2

用途:

document.URL; 

或者

window.location.href