即使在注入http之后,Uncaught TypeError:无法读取属性' get'未定义的

时间:2015-10-03 09:47:47

标签: javascript angularjs

我有以下简单的代码,但即使注入了$ 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');
         });
    }
}

未捕获的TypeError:无法读取属性' get'未定义的 我错过了什么?

1 个答案:

答案 0 :(得分:3)

您的控制器中已经有$scope$http,因此您无需将它们作为参数传递给函数refresh。变化

$scope.refresh = function($scope, $http) {

$scope.refresh = function() {

它应该都可以正常工作