您的位置:首页 > Web前端 > AngularJS

[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.



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: