作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下简单的代码,但即使注入(inject)了 $http,我也会收到错误:
angular.module('bizapp')
.controller('SalesCtrl', ['$scope', '$http', GetSalesInvoices]);
function GetSalesInvoices($scope, $http) {
$scope.invoices = [];
$scope.refresh = function($scope, $http) {
var url = "https://foo.ic/api/salesinvoice/SalesInvoices";
$http.get(url)
.success(function(data) {
$scope.invoices = data.d.results;
})
.error(function(){
console.log('opss')
})
.finally(function() {
$scope.$broadcast('scroll.refreshComplete');
});
}
}
未捕获的类型错误:无法读取未定义的属性“get”我错过了什么?
最佳答案
您的 Controller 中已经有 $scope
和 $http
,因此您不需要将它们作为参数传递给函数 refresh
。变化
$scope.refresh = function($scope, $http) {
到
$scope.refresh = function() {
一切正常
关于javascript - 即使在注入(inject) http 之后,Uncaught TypeError : Cannot read property 'get' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32921151/
我是一名优秀的程序员,十分优秀!