1

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.

derloopkat
  • 6,232
  • 16
  • 38
  • 45
  • 1
    related fix not applicable as spelling is correct. - https://stackoverflow.com/questions/32933725/httpbackend-whenget-is-not-a-function-in-angular – dale thompson Oct 16 '21 at 20:25

1 Answers1

0

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) { // ... }]);

Glen Blanchard
  • 926
  • 8
  • 17
  • Hey bro I have - copied the annotation done with the other services we picked up and it still runs through $httpbackend is undefined or when minified n is undefined - also when adjust whenGET to when.get it does a similar thing either n.whenGET undefined or not a function – dale thompson Oct 16 '21 at 20:21
  • Did you install ngMockE2E https://code.angularjs.org/1.6.10/docs/api/ngMockE2E/service/$httpBackend – Glen Blanchard Oct 16 '21 at 21:34
  • Yeah I have installed as well - I wonder if the external scripts are ordered correctly, matched the order but there may be something I missed – dale thompson Oct 18 '21 at 19:32