在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.
答案 0 :(得分:5)
有一个错字。模块名称是驼峰式的。改变
{{1}}
到
{{1}}
答案 1 :(得分:1)
oc lazyload的依赖项应添加为oc.lazyLoad
而不是oc.lazyload
<强> app.js 强>
(function () {
angular.module('app', ['ui.router', 'oc.lazyLoad']);
angular.element(document).ready(function () {
angular.bootstrap(document, ["app"]);
});
})();
答案 2 :(得分:1)
我也有这个错误,即使我没有任何拼写错误,我也按照https://oclazyload.readme.io/docs的配置说明进行操作。我在Ruby on Rails中使用Angular,我的错误是通过在我的 app / assets / javascripts / application.js 文件中添加以下行来修复的:
//= require oclazyload