2016-05-29 55 views
3

從2016年5月(RC1)最新變化現在有@Routes,沒有更多的@RouteConfig在那裏我可以用newAsyncRoute以異步加載該組件。Angular2.0.0-RC1異步路由器

的文檔還沒有準備好Angular.io,任何人知道如何在這種情況下,現在使用異步路由器新的路由,如:

@Routes([ 
     { path: '/first', component: FirstComponent }, 
     { path: '/second', component: SecondComponent } 
    ]) 

感謝。

回答

0

這不適用於新的RC.3路由器。對於異步路由新的方式似乎是在它的途中

喜歡的東西

@Routes([ 
    { path: '/first', component: 'app.first.component.js' }, 
    { path: '/second', component: 'app.second.component.js' } 
]) 

參見https://github.com/angular/angular/issues/8861https://github.com/angular/angular/pull/8455/files(搜索@Routes

+0

謝謝,我會試試看。 – swentk

+3

好,所以實際上,在我從NG會議中發現這個視頻後,我想到了......關鍵是你將組件放在引號中以打破依賴關係,然後system.js將在之後加載它:https://www.youtube。 COM /手錶?ν= d8yAdeshpcw&指數= 9 =名單PLOETEcp3DkCq788xapkP_OU-78jhTf68j – swentk