[Angular 2] Keynote: Lazy Routing -- NGCONF
2016-05-31 02:15
525 查看
So How to do lazy loading for router in Angular 2.
The nomarl way to write a router in Angular 2:
You have SimpleCmp and UserCmp as child components. You also import {SimpleCmp, UserCmp} from 'xxxxxx'.
It will not be lazy loaded. Because you already have the reference to the child component.
But it turn out to be very easy to enable the lazy loading:
Just add '' to SimpleCmp and UserCmp.
Then you need to follow the convention of how to name the folder.
The '+' symbol means those folders are lazy loaded. So Component is called UserCmp, the folder should be named as 'user-cmp'. OKOK, not tooo bad.
The nomarl way to write a router in Angular 2:
You have SimpleCmp and UserCmp as child components. You also import {SimpleCmp, UserCmp} from 'xxxxxx'.
It will not be lazy loaded. Because you already have the reference to the child component.
But it turn out to be very easy to enable the lazy loading:
Just add '' to SimpleCmp and UserCmp.
Then you need to follow the convention of how to name the folder.
The '+' symbol means those folders are lazy loaded. So Component is called UserCmp, the folder should be named as 'user-cmp'. OKOK, not tooo bad.
相关文章推荐
- AngularJs(七) 模块的创建
- AngularJs入门实例
- angularjs 使用ng-repeat报错
- [AngularJS] Default Child state and nav between child state
- AngularJs(四)控制器
- AngularJs(三)作用域
- AngularJS 不得不了解的服务 $compile 用于动态显示html内容
- 第五章 表单
- 给你一个承诺 - 玩转 AngularJS 的 Promise
- Echart的angularjs封装
- 基于AngularJs + Bootstrap + AngularStrap相结合实现省市区联动代码
- 基于Angularjs实现分页功能
- angularJs中directive的scope ‘@’,‘=’区别
- AngularJs实现分页功能不带省略号的代码
- 数据驱动视图简单实现
- 第四章 内建组件
- AngularJs表单验证实例详解
- angular中的路由简单使用
- AngularJS自定义表单验证
- AngularJS ng-options下拉菜单绑定数值