【发布时间】:2017-05-02 19:25:19
【问题描述】:
我正在尝试获取最初在浏览器中输入的 URL 的参数。但是 Angular 会自动将我“重定向”到 '/'
比如我输入这个网址: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: {
'testView@' : {
templateUrl: '/app/test/test.html',
controller: 'test.controller',
controllerAs: 'testVM'
}
}
});
这是为什么呢?有没有办法获取原始网址?
【问题讨论】:
-
显示你的路线定义
标签: angularjs angular-ui-router angular-http-interceptors