1
我正在嘗試獲取最初在瀏覽器中輸入的網址的參數。但角 「重定向」 我自動'/'
在AngularJS中重定向之前獲取在瀏覽器中輸入的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: {
'[email protected]' : {
templateUrl: '/app/test/test.html',
controller: 'test.controller',
controllerAs: 'testVM'
}
}
});
這是爲什麼?有沒有辦法獲得原始網址?
顯示你的路由定義 – Ladmerc