3

在 html 中,我在 app.js 之前加载了 oclazyload -

<!-- 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>

我的 app.js -

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

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

但由于某种原因,它根本不加载oc.lazyload模块。可能是什么问题?我错过了什么吗?

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.
4

3 回答 3

6

有一个错字。模块名称为驼峰式。改变

'oc.lazyload'

'oc.lazyLoad' //'L' capitalized
于 2015-11-29T08:27:38.267 回答
1

应该添加 oc lazyload 的依赖项,oc.lazyLoad而不是oc.lazyload

应用程序.js

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

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

参考

于 2015-11-29T08:28:42.357 回答
1

我也遇到了这个错误,即使我没有任何拼写错误并且我按照https://oclazyload.readme.io/docs上的配置说明进行操作。我在 Ruby on Rails 中使用 Angular,通过将下面的行添加到我的app/assets/javascripts/application.js文件中来修复我的错误:

//= require oclazyload
于 2016-03-11T15:48:54.747 回答