Angular JS TypeError:$http不是函数
Angular JS TypeError: $http is not a function
我已经通读了所有的帖子,在这些帖子中,人们遇到了这个问题,其中$http不是一个函数,而且在大多数情况下,这似乎是由于注入顺序错误。
我的模块定义如下:
angular.module("app", []).controller("appCtrl", ['$scope','$http',
function ($scope, $http) {
...
$scope.makeCall= function ($http) {
console.log("HERE");
$http({ method: 'GET', url: <url }).
then(function (response) {
console.log(response.data);
return response.data;
}, function (response) {
});
};
}
])
如有任何建议,我们将不胜感激。
从makeCall
函数中删除$http
参数,这将扼杀通过控制器注入的$http
依赖关系的存在。基本上,当你在函数上添加它时,它被设置为undefined
$scope.makeCall= function () { //<-- removed $http dependency from here
console.log("HERE");
$http({ method: 'GET', url: 'url' })
.then(function (response) {
console.log(response.data);
return response.data;
}, function (response) {
}
);
};
相关文章:
- 存储$http如何从$http函数(Angularjs)外部获取可访问变量中的响应
- 如何使用(this)访问Angular 2 http rxjs catch函数中的对象属性
- AngularJs.调用$http.success中的jQuery函数
- 在http服务单元测试中使用request-js时,chai.request不是一个函数
- 返回$http内的父函数
- 如何将多个onError函数分配给promise(由angular's$http.post返回)
- 正在等待HTTP调用从函数返回结果
- AngularJS:如何获取$http结果作为函数的返回值
- $http.post undefined 不是函数
- $http.post() angularjs 响应函数未按正确的顺序执行
- 在导出函数 MEANJS 中编写 Http 请求
- Angularjs$http删除$q promise导致TypeError:对象不是函数
- Cordova Http插件:postJSON不是函数
- AngularJS http.jsonp请求.then和.success函数不起作用
- "对象不是函数“;当将Node.js HTTP服务器对象传递给Socket.IO时
- Angular JS TypeError:$http不是函数
- 循环AngularJS$http调用-TypeError:对象不是函数
- 如何使用$q's构造函数语法与Angular$http's配置超时
- 未定义的函数:$http.post 中的 .succes (角度.js)
- Angular:从父函数$http中返回id