码迷,mamicode.com
首页 > 其他好文 > 详细

[Angular 2] Keynote: Lazy Routing -- NGCONF

时间:2016-05-31 06:26:48      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:

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.

 

技术分享

技术分享

[Angular 2] Keynote: Lazy Routing -- NGCONF

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/5544546.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!