0

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?

3
  • 1
    please check again there are 9 modules are injected and you have 10 arguments in function, so you are doing same mistake other doing :p Commented Jan 5, 2016 at 8:49
  • Yep, I see that now, thank you :) What a dolt! Commented Jan 5, 2016 at 8:52
  • Double checking is not enough, triple check it!!! Commented Jan 5, 2016 at 8:52

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.