We've looked at lazy loading with ocLazyLoad previously, but what if we are using ui-router and want to lazy load modules when we change states?

angular.module("demo", ["ui.router", "oc.lazyLoad"])
.config(function ($stateProvider) {
$stateProvider.state('store', {
templateUrl: "store/store.html",
controller: "StoreCtrl as store",
resolve: {
store: function ($ocLazyLoad) {
return $ocLazyLoad.load(
{
name: "store",
files: ["store/store.js"]
}
)
}
}
})
}) .controller("AppCtrl", function ($state) {
var app = this;
app.click = function () {
$state.go("store")
}
})

[AngularJS] Lazy Loading modules with ui-router and ocLazyLoad的更多相关文章

  1. [AngularJS] Lazy loading Angular modules with ocLazyLoad

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

  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. [Angular2 Router] Lazy Load Angular 2 Modules with the Router

    Angular 2 lazy loading is a core feature of Angular 2. Lazy loading allows your application to start ...

  4. AngularJS 使用 UI Router 实现表单向导

    Today we will be using AngularJS and the great UI Router and the Angular ngAnimate module to create ...

  5. angularjs ngRoute和ui.router对比

    ngRoute模块是angularjs自带的路由模块,ui.router是一个第三方路由模块,接下来将对两者进行一个对比: ng-router(angular-router.js) ng-view n ...

  6. [转]AngularJS 使用 UI Router 实现表单向导

    本文转自:http://www.oschina.net/translate/angularjs-multi-step-form-using-ui-router 今天我们将使用AngularJs和伟大的 ...

  7. [转]AngularJS+UI Router(1) 多步表单

    本文转自:https://www.zybuluo.com/dreamapplehappy/note/54448 多步表单的实现   在线demo演示地址https://rawgit.com/dream ...

  8. angularJS ui router 多视图单独刷新问题

    场景:视图层级如下 view1 --view11 --view111 需求:view11的一个动作过后,单独刷新view12 解决方式:修改层级设计 view1 --view11 --view111 ...

  9. ngRoute 和 ui.router 的使用方法和区别

    在单页面应用中要把各个分散的视图给组织起来是通过路由机制来实现的.本文主要对 AngularJS 原生的 ngRoute 路由模块和第三方路由模块 ui.router 的用法进行简单介绍,并做一个对比 ...

随机推荐

  1. memcache 分布式,算法实现

    memcached 虽然称为 “ 分布式 ” 缓存服务器,但服务器端并没有 “ 分布式 ” 功能.每个服务器都是完全独立和隔离的服务. memcached 的分布式,则是完全由客户端程序库实现的. 这 ...

  2. 【windows核心编程】DLL相关(3)

    DLL重定向 因为DLL的搜索路径有先后次序,假设有这样的场景:App1.exe使用MyDll1.0.dll, App2.exe使用MyDll2.0.dll, MyDll1.0 和 MyDll2.0是 ...

  3. cocos2d-x 详解之 CCSprite(精灵)- “CCSpriteBatchNode”和“CCSpriteFrameCache”

    帧动画-手动切换帧-批次渲染处理动画-纹理图片的本质 ------------------------------------------------------------------------- ...

  4. 关于“心脏出血”漏洞(heartbleed)的理解

    前阵子“心脏出血”刚发生的时候读了下源代码,给出了自己觉得比较清楚的理解.   -------------------------穿越时空的分割线--------------------------- ...

  5. nservicebus教程-目录

    表的内容 开始 坚持NServiceBus 扩展 每天 举办 管理和监控 发布订阅 长时间运行的流程 定制 版本控制 常见问题解答 样品 开始 概述 NServiceBus一步一步向导 架构原则 事务 ...

  6. My First Blog on cnblogs (现代程序设计 Homework-01)

    Hello CNBLOGS!Hello Everyone! 这是我的第一篇blog,所以这也是一篇试验性的blog. 这个学期我和很多同学一样选修了邹欣老师的现代程序设计这门专业课.第一次看到使用Gi ...

  7. Linux 获取文件时间信息 判断文件是否存在

    获取文件时间戳   (1)查看全部信息: stat e4.txt 范例: [root@localhost ~]# stat e4.txt File: “e4.txt” Size: 0 Blocks: ...

  8. BestCoder Round #73 (div.2)(hdu 5630)

    Rikka with Chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  9. [C语言 - 7] 结构体struct

    A. 基本知识   与数组的对比 数组: 构造类型 只能有多个相同类型的数据构成   结构体: 结构体类型 可以由多个不同类型的数据构成   1. 定义类型 struct Student { int ...

  10. 解北大OJ1088滑雪问题的记录

    问题: Time Limit:1000MS   Memory Limit:65536K Total Submissions:67600   Accepted:24862 Description Mic ...