我正在尝试使用拦截器的基本示例,所以我盯着一小段代码但没有成功:
var app = angular.module('app',[]).
config(['$routeProvider','$locationProvider', function($routeProvider,$location) {
$routeProvider.
when('/home', {templateUrl: 'home.html', controller: homeCtrl}).
when('/login', {templateUrl: 'login.html', controller: loginController}).
otherwise({redirectTo : '/home' });
}]);
app.config(function ($httpProvider) {
$httpProvider.interceptors.push('httpRequestInterceptor');
});
当我启动我的索引页面时,我在控制台中有一条错误消息:
Uncaught TypeError: Cannot call method 'push' of undefined from app
任何想法?
谢谢