ocLazyload not loading the module

橙三吉。 提交于 2019-12-12 13:51:36

问题


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.

回答1:


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

'oc.lazyload'

to

'oc.lazyLoad' //'L' capitalized



回答2:


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




回答3:


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


来源:https://stackoverflow.com/questions/33980814/oclazyload-not-loading-the-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!