NoGall
NoGall

Reputation: 5246

Cannot read property 'get' of undefined and $http is not a function - Angular

I'm quite new to Angular and I'm having issues with injecting $http into the following controller:

function(){
    angular.module('nps-settings-support-tools', [])
        .controller('SettingsSupportToolsController', [ '$scope', 'Settings', 'gettextCatalog', '$q', '$timeout',
            '$rootScope', 'SweetAlert', 'CurrentUser', '$http',
            function($scope, Settings, gettextCatalog, $q, UploadFile, $timeout, $rootScope, SweetAlert, CurrentUser, $http) {
                var apiUrl = '/api/v1/';

I've read here that Angular cares greatly about the order of injections, but I've double-checked that the ordering is correct. Yet, when I'm running:

$scope.doTodo = function() {
    return $http.get(apiUrl + 'support?tool=digest&type=todo');
};

I get the following errors in the console:

TypeError: Cannot read property 'get' of undefined
    at Scope.$scope.doDetractors

So, thinking that my memory was incorrect, I also tried with:

return $http({url: apiUrl + 'support?tool=digest&type=responses', method: 'GET'});

Which obviously fails also because $http appears to be undefined, yet I can't see where I've gone wrong, as most SO questions / answers are about ordering of injections and accessing $http via an improperly ordered injection, which I'm not doing (as far as I can see).

Does anyone know what is going on, please?

Upvotes: 0

Views: 173

Answers (1)

www.admiraalit.nl
www.admiraalit.nl

Reputation: 6099

You have parameter UploadFile in the controller function, but not in the array of strings.

Upvotes: 2

Related Questions