首页 > 其他 > 详细

[Angular 2] Keynote: Lazy Routing -- NGCONF

时间:2016-05-31 06:23:31      阅读:180      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!