Home > Blockchain >  How do I fix "Uncaught TypeError: can't access property "whenGET", $httpBackend
How do I fix "Uncaught TypeError: can't access property "whenGET", $httpBackend

Time:10-19

I am trying to use the following https://embed.plnkr.co/plunk/pWNOdA in a project that uses strict-DI.

In the app-mockbackend.js you can see the following setup -

angular.module('app').run(function($httpBackend, ServerDataModel) {
    
    $httpBackend.whenGET('/games').respond(function(method, url, data) {
        var games = ServerDataModel.findAll();
        return [200, games, {}];
    });
}]);

When you run the app without strict it runs fine, but when you add ng-strict-di to your app I get:

Uncaught TypeError: can't access property "whenGET", $httpBackend is undefined

I have read the docs and with other areas, I have had to annotate services while using strict and the errors have subsided and it's great - I just cannot seem to figure this one out.

CodePudding user response:

Hey Dale did you try to annotate the function?

https://docs.angularjs.org/guide/di#dependency-annotation

For example:

someModule.controller('MyController', ['$scope', 'greeter', function($scope, greeter) { // ... }]);

CodePudding user response:

For those who ever see this - check your services Glen had the right idea. Spelling error in the service ngMockE2E - I had it wrong.

  • Related