Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ocLazyload not loading the module

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.
like image 678
Joy Avatar asked Feb 07 '26 11:02

Joy


2 Answers

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

'oc.lazyload'

to

'oc.lazyLoad' //'L' capitalized
like image 142
Tarun Dugar Avatar answered Feb 08 '26 23:02

Tarun Dugar


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

like image 26
Vivek Avatar answered Feb 08 '26 23:02

Vivek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!