3

In html I am loading the oclazyload before my app.js -

<!-- inject:js -->
        <script src="/packages/libs/jquery/dist/jquery.js"></script>
        <script src="/packages/libs/angular/angular.js"></script>
        <script src="/packages/libs/oclazyload/dist/ocLazyLoad.js"></script>
        <script src="/packages/libs/angular-ui-router/release/angular-ui-router.js"></script>
        <!-- endinject -->

        <script src="app/app.js" ></script>
        <script src="app/common/app.config.js" charset="utf-8"></script>

My app.js -

(function () {
    angular.module('app', ['ui.router', 'oc.lazyload']);

    angular.element(document).ready(function () {
        angular.bootstrap(document, ["app"]);
    });
})();

But for some reason it doesn't load the oc.lazyload module at all . what might be the problem ? Am I missing something ?

Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:modulerr] Failed to instantiate module oc.lazyload due to:
Error: [$injector:nomod] Module 'oc.lazyload' 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.
Joy
  • 6,438
  • 8
  • 44
  • 75

3 Answers3

6

There is a typo. The module name is camel case. Change

'oc.lazyload'

to

'oc.lazyLoad' //'L' capitalized
Tarun Dugar
  • 8,921
  • 8
  • 42
  • 79
1

The dependency for oc lazyload should be added as oc.lazyLoad instead of oc.lazyload

app.js

(function () {
    angular.module('app', ['ui.router', 'oc.lazyLoad']);

    angular.element(document).ready(function () {
        angular.bootstrap(document, ["app"]);
    });
})();

Reference

Vivek
  • 11,938
  • 19
  • 92
  • 127
1

I also had this error, even though I did not have any typos and I followed the configuration directions at https://oclazyload.readme.io/docs. I was using Angular within Ruby on Rails, and my error was fixed by adding the line below to my app/assets/javascripts/application.js file:

//= require oclazyload
kales33
  • 670
  • 8
  • 23