AngularJS $httpProvider未定义

前端之家收集整理的这篇文章主要介绍了AngularJS $httpProvider未定义前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图使用拦截器的基本样本,所以我盯着一小段代码,但没有成功:
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.版本1.1.4中添加了$http.interceptors数组.

我用你的例子和棱镜1.1.4做了一个plunker,在这里查看http://plnkr.co/edit/cuPfat?p=preview

原文链接:https://www.f2er.com/angularjs/142356.html

猜你在找的Angularjs相关文章