我'嘗試使用攔截器的基本樣本,所以我用一小段代碼,但沒有成功瞪大了眼睛:
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
任何想法?
由於
檢查angularjs版和$相應的HTTP版本文檔。問題可能與版本有關。 – Chandermani