Recentlly works with AngularJS + ocLazyLoad, our project have break down into multi small modules. For example

mainApp module

| -- vendor module

| -- child 1 module

| -- child 2 module

| -- ....

'vendor, child1, child2' they are spreated npm modules.

'vendor' contains all the common used libs. Because we have multi AngularJS projects on going, vendor module is shared among all of them.

One problem I met when apply lazy loaded is that, for example, I want to lazy load Child1 module, any child 1 module contains a lib call angular-scroll which locates in vendor module. And mainApp Module doesn't use angular-scroll lib.

angular.module('Child1', ['duScroll'])

When I lazy load Child1, it reports error that:

'duScroll'Provider' is not found

Because Child1 doesn't have this lib included, this lib was included in vendor module, ocLazyLoad requires:

lazy loaded modules should contains all the dependencies code, unless the dependencies was already declare in main app module

So the solution to solve the problem is include 'duScroll' into mainApp module:

angular.module('mainApp', ['duScroll'])

[AngularJS] ocLazyLoad -- Lazy loaded module should contain all the dependencies code的更多相关文章

  1. angularjs ocLazyLoad分步加载js文件,angularjs ocLazyLoad按需加载js

    用angular有一段时间了,平日里只顾着写代码,没有注意到性能优化的问题,而今有时间,于是捋了捋,讲学习过程记录于此: 问题描述:由于采用angular做了网页的单页面应用,需要一次性在主布局中将所 ...

  2. [Angular Router] Lazy loading Module with Auxiliary router

    Found the way to handle Auxiliary router for lazy loading moudle and erge load module are different. ...

  3. AngularJS系统学习之Module(模块)

    本文源自:http://blog.csdn.net/woxueliuyun/article/details/50962645 学习之后略有所得, 来此分享.建议看原文. 模块是提供一些特殊服务的功能块 ...

  4. Angular2 - Starter - Routes, Route Resolver

    在基于Angualr的SPA中,路由是一个很重要的部分,它帮助我们更方便的实现页面上区域的内容的动态加载,不同tab的切换,同时及时更新浏览器地址栏的URN,使浏览器回退和前进能导航到历史访问的页面. ...

  5. [AngularJS] Lazy loading Angular modules with ocLazyLoad

    With the ocLazyLoad you can load AngularJS modules on demand. This is very handy for runtime loading ...

  6. AngularJS Providers 详解

    供应者(Providers) Each web application you build is composed of objects that collaborate to get stuff d ...

  7. Angularjs 异步模块加载项目模板

    ng-lazy-module-seed(Angularjs 异步模块加载项目模板) 相信做过SPA项目的朋友都遇到过这个问题:页面初始化时需要加载文件太大或太多了,许多文件加载后很可能不会运行到,这是 ...

  8. Angular-ui-router + oclazyload + requirejs实现资源随route懒加载

    刚开始用angularjs做项目的时候,我用的是ng-router,觉得加载并不好.所以就用了ui-router,考虑到在app上网页加载速度太慢,所以我就想到了用懒加载,看下是否能提升性能,提高加载 ...

  9. AngularJS基础总结

    w3shools    angularjs教程  wiki   <AngularJS权威教程> Introduction AngularJS is a JavaScript framewo ...

随机推荐

  1. jQuery 的DOM操作

    DOM创建节点及节点属性 创建元素:document.createElement设置属性:setAttribute添加文本:innerHTML加入文档:appendChild append()前面是被 ...

  2. AWT编程时,Button按钮上的中文编程□□□

    今天学到AWT编程时,照着书上的代码打,代码如下: import java.awt.*; public class PanelTest{    public static void main(Stri ...

  3. 洛谷 P1569 [USACO11FEB]属牛的抗议Generic Cow Prote…

    题目描述 Farmer John's N (1 <= N <= 100,000) cows are lined up in a row and numbered 1..N. The cow ...

  4. CentOS7 Install Shipyard

    # 采集木jj 原文:http://www.cnblogs.com/caoguo/p/5735189.html # CentOS7 Install Shipyard# yum install dock ...

  5. samba的安装及其使用

    参考pdf文档:https://pan.baidu.com/s/1iPJ1iPtNx7ZXNHRurrjfqw centos7 samba配置#centos7安装Sambayum -y install ...

  6. 解决vue项目eslint校验 Do not use 'new' for side effects 的两种方法

    import Vue from 'vue' import App from './App.vue' import router from './router' new Vue({ el: '#app' ...

  7. android studio 调试安装

    最新的手机无法debug安装调试. vivo x21  oppo r11等 解决办法: 1,关闭instant run Android Studio->Preferences->Build ...

  8. 模板—trie图

    做了某题之后发现trie的AC自动机太垃圾了,动不动就TLE,然后我就去学了trie图. #include<iostream> #include<cstdio> using n ...

  9. git Please tell me who you are解决方法

    在git创建项目时出现,是因为在创建git文件夹的时候信息不完善导致的下图是正确在git创建项目时出现,是因为在创建git文件夹的时候信息不完善导致的下图是正确1.git init2.git conf ...

  10. 操作iframe的方法

    子页面 <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8&q ...