在 AngularJS 中重定向之前在浏览器中输入 URL?
Getting the URL entered in browser before redirection in AngularJS?
我正在尝试获取最初在浏览器中输入的 URL 的参数。但是angular"redirects"我自动给'/'
例如,我输入这个URL:http://localhost:9080/#/test?param1=en¶m2=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'
}
}
});
这是为什么?有没有办法得到原来的 URL ?
使用:
document.URL;
或者
window.location.href
我正在尝试获取最初在浏览器中输入的 URL 的参数。但是angular"redirects"我自动给'/'
例如,我输入这个URL:http://localhost:9080/#/test?param1=en¶m2=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'
}
}
});
这是为什么?有没有办法得到原来的 URL ?
使用:
document.URL;
或者
window.location.href