【问题标题】:$http.get() error : $http.get is not a function$http.get() 错误:$http.get 不是函数
【发布时间】:2017-12-20 10:34:30
【问题描述】:

我正在创建一个 dataService 来处理所有 http 连接,这是我的代码:

(function(){
angular.module('theswapp')
       .factory('dataService',['$http','$q',function($q, $http){

        function getTeamCheckInData(){
            return $http.get('assets/js/data.json');
        }

        return {
            getTeamCheckInData : getTeamCheckInData
        };

  }]);
})();

在我的控制器中注入它并调用它后,我在 return $http.get('assets/js/data.json'); 处遇到错误。错误说 $ http.get 不是函数

【问题讨论】:

    标签: angularjs http angular-services


    【解决方案1】:

    工厂参数顺序错误,应该是

    angular.module('theswapp')
           .factory('dataService',['$http','$q',function($http,$q ){
    

    【讨论】:

      猜你喜欢
      • 2017-05-01
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 2017-05-02
      • 1970-01-01
      • 2016-10-02
      相关资源
      最近更新 更多