我想在我的路由中获取在 http 请求中发送的配置(例如,url)。这是我的路线:
angular.module('myApp', ['myApp.directives', 'myApp.services', 'myApp.filters']).config(
function($routeProvider, $locationProvider, $httpProvider) {
$locationProvider.html5Mode(false);
$locationProvider.hashPrefix('!');
$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
$routeProvider.
when('/', {
templateUrl: 'elements/home/home.html',
controller: homeCtrl
});
});
angular.module('myApp').run(function($rootScope, $location, $http) {
pendingRequests = {};
$rootScope.$watch(function() {
return $location.url();
},
function(newRoute) {
console.log(newRoute);
var requestUrl = ?
pendingRequests[newRoute] = 0;
});
});
现在在运行模块中,我希望为 $location.url() 发送请求 url
有人知道吗?