AngularJS $ httpProvider未定义 [英] AngularJS $httpProvider undefined
本文介绍了AngularJS $ httpProvider未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我'尝试使用拦截器的基本样本,所以我用一小片code,但没有成功瞪大了眼睛:
I'am trying to use a basic sample of interceptors, so I stared with a little piece of code but without success:
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');
});
当我启动我的索引页我在控制台的错误消息:
When I launch my index page I have an error message in the console :
Uncaught TypeError: Cannot call method 'push' of undefined from app
任何想法?
感谢
推荐答案
您code是完美的。你需要确保你正在使用angularjs的正确版本。在1.1.4版本中添加了$ http.interceptors阵列。
Your code is perfect. You need to make sure you are using the correct version of angularjs. The $http.interceptors array was added in version 1.1.4.
我做你的榜样具有角1.1.4工作一个plunker,看看这里的http:// plnkr.co/edit/cuPfat?p=$p$pview
I made a plunker with your example working with angular 1.1.4, check it out here http://plnkr.co/edit/cuPfat?p=preview
这篇关于AngularJS $ httpProvider未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文