Mawg
Mawg

Reputation: 40150

AngularJs injection error

My sample, very basic, skeleton app works just fine. Then I tried to add @MaximShoustin answer from this question - Plunk here.

And I get

jquery-3.1.1.min.js:2 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.0/$injector/modulerr?p0=inspinia&p1=Error%3A%20%5B%24injector%3Amodulerr%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.5.0%2F%24injector%2Fmodulerr%3Fp0%3Doc.lazyLoad%26p1%3DError%253A%2520%255B%2524injector%253Anomod%255D%2520http%253A%252F%252Ferrors.angularjs.org%252F1.5.0%252F%2524injector%252Fnomod%253Fp0%253DngSanitize%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A6%253A416%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A25%253A136%250A%2520%2520%2520%2520at%2520b%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A24%253A188)%250A%2520%2520%2520%2520at%2520Object.module%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A24%253A431)%250A%2520%2520%2520%2520at%2520u%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fplugins%252Foclazyload%252Fdist%252FocLazyLoad.min.js%253A8%253A2925)%250A%2520%2520%2520%2520at%2520Object.n%2520%255Bas%2520forEach%255D%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A7%253A355)%250A%2520%2520%2520%2520at%2520u%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fplugins%252Foclazyload%252Fdist%252FocLazyLoad.min.js%253A8%253A2994)%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fplugins%252Foclazyload%252Fdist%252FocLazyLoad.min.js%253A8%253A3048%250A%2520%2520%2520%2520at%2520Object.n%2520%255Bas%2520forEach%255D%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A7%253A355)%250A%2520%2520%2520%2520at%2520u%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fplugins%252Foclazyload%252Fdist%252FocLazyLoad.min.js%253A8%253A3026)%250A%2520%2520%2520%2520at%2520new%2520%253Canonymous%253E%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fplugins%252Foclazyload%252Fdist%252FocLazyLoad.min.js%253A8%253A3511)%250A%2520%2520%2520%2520at%2520Object.instantiate%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A41%253A396)%250A%2520%2520%2520%2520at%2520c%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A38%253A348)%250A%2520%2520%2520%2520at%2520Object.provider%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A38%253A290)%250A%2520%2520%2520%2520at%2520d%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A39%253A234)%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A39%253A340%250A%2520%2520%2520%2520at%2520n%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A7%253A355)%250A%2520%2520%2520%2520at%2520g%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A39%253A135)%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A39%253A304%250A%2520%2520%2520%2520at%2520n%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A7%253A355)%250A%2520%2520%2520%2520at%2520g%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A39%253A135)%250A%2520%2520%2520%2520at%2520fb%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A43%253A164)%250A%2520%2520%2520%2520at%2520c%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A20%253A449)%250A%2520%2520%2520%2520at%2520Ac%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A21%253A259)%250A%2520%2520%2520%2520at%2520fe%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A20%253A69)%250A%2520%2520%2520%2520at%2520HTMLDocument.%253Canonymous%253E%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fangular%252Fangular.min.js%253A306%253A372)%250A%2520%2520%2520%2520at%2520j%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fjquery%252Fjquery-3.1.1.min.js%253A2%253A29948)%250A%2520%2520%2520%2520at%2520k%2520(http%253A%252F%252Flocalhost%252Fa%252Fjs%252Fjquery%252Fjquery-3.1.1.min.js%253A2%253A30262)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%2Fa%2Fjs%2Fangular%2Fangular.min.js%3A6%3A416%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%2Fa%2Fjs%2Fangular%2Fangular.min.js%3A40%3A60%0A%20%20%20%20at%20n%20(http%3A%2F%2Flocalhost%2Fa%2Fjs%2Fangular%2Fangular.min.js%3A7%3A355)%0A%20%20%20%20at%20g%20(http%3A%2F%2Flocalhost%2Fa%2Fjs%2Fangular%2Fangular.min.js%3A39%3A135)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%2Fa%2Fjs%2Fangular%2Fangular.min.js%3A39%3A304%0A%20%20%20%20at%20n%20(http%3A%2F%2Flocalhost%2Fa%2Fjs%2Fangular%2Fangular.min.js%3A7%3A355)%0A%20%20%20%20at%20g%20(http%3A%2F%2Flocalhost%2Fa%2Fjs%2Fangular%2Fangular.min.js%3A39%3A135)%0A%20%20%20%20at%20fb%20(http%3A%2F%2Flocalhost%2Fa%2Fjs%2Fangular%2Fangular.min.js%3A43%3A164)%0A%20%20%20%20at%20c%20(http%3A%2F%2Flocalhost%2Fa%2Fjs%2Fangular%2Fangular.min.js%3A20%3A449)%0A%20%20%20%20at%20Ac%20(http%3A%2F%2Flocalhost%2Fa%2Fjs%2Fangular%2Fangular.min.js%3A21%3A259)%0A%20%20%20%20at%20fe%20(http%3A%2F%2Flocalhost%2Fa%2Fjs%2Fangular%2Fangular.min.js%3A20%3A69)%0A%20%20%20%20at%20HTMLDocument.%3Canonymous%3E%20(http%3A%2F%2Flocalhost%2Fa%2Fjs%2Fangular%2Fangular.min.js%3A306%3A372)%0A%20%20%20%20at%20j%20(http%3A%2F%2Flocalhost%2Fa%2Fjs%2Fjquery%2Fjquery-3.1.1.min.js%3A2%3A29948)%0A%20%20%20%20at%20k%20(http%3A%2F%2Flocalhost%2Fa%2Fjs%2Fjquery%2Fjquery-3.1.1.min.js%3A2%3A30262)
    at angular.js:38
    at angular.js:4526
    at n (angular.js:321)
    at g (angular.js:4487)
    at fb (angular.js:4409)
    at c (angular.js:1691)
    at Ac (angular.js:1712)
    at fe (angular.js:1606)
    at HTMLDocument.<anonymous> (angular.js:30423)
    at j (jquery-3.1.1.min.js:2)
    at k (jquery-3.1.1.min.js:2)

Here's what ought to be the relevant code to inject $sce and $sanitize (I added the last two parameters to the controller and the last entry in the module) - what am I doing wrongly?

function MainCtrl($rootScope, $scope, $http, $interval, $state, $location, $sanitize, $sce)

and

(function () {
    angular.module('inspinia', [
        'ui.router',                    // Routing
        'oc.lazyLoad',                  // ocLazyLoad
        'ui.bootstrap',                 // Ui Bootstrap
        'ui.grid',                      // Grid
        'ngSanitize'
    ])
})();

beyond that, the only change is to add

<iframe ng-src="{{cvTrustedUrl}}"></iframe> 

into the view


[Update] I injected ngSantize, but now I get

angular-sanitize.js:19 Uncaught TypeError: Cannot read property '$$minErr' of undefined at angular-sanitize.js:19 at angular-sanitize.js:6 (anonymous) @ angular-sanitize.js:19 (anonymous) @ angular-sanitize.js:6

Upvotes: 0

Views: 551

Answers (1)

Estus Flask
Estus Flask

Reputation: 222493

Error message contains a link to the page where the cause of the problem is explained in human-readable form with a stack of errors:

Failed to instantiate module oc.lazyLoad due to:

Error: [$injector:nomod] http://errors.angularjs.org/1.5.0/$injector/nomod?p0=ngSa...

and

Module 'ngSanitize' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

ngSanitize module should be loaded at the moment when the application is being bootstrapped.

It is also preferable to use unminified packages in order to improve the readability of call stack.

Upvotes: 1

Related Questions