2016-06-18 38 views
0

我使用社交應用教程學習Angular2Meteor。我遇到了一個我找不到根本原因的問題。使用routeconfig時,無法讀取未定義的屬性'註釋'

我跟隨tutorial,指出補充:

RouteConfig註釋:

@RouteConfig([ 
    { 
    path: '/', 
    as: 'PartiesList', 
    component: PartiesList 
    }, { 
    path: '/party/:partyId', 
    as: 'PartyDetails', 
    component: PartyDetails 
    } 
]); 

在app.html router-outlet

<router-outlet></router-outlet> 

我加載的時候得到這個例外Chrome中的應用:

EXCEPTION: Error in /client/app.html:0:0BrowserDomAdapter.logError @ 
modules.js?hash=12bd683…:59337BrowserDomAdapter.logGroup @ modules.js? 
hash=12bd683…:59347ExceptionHandler.call @ modules.js? 
hash=12bd683…:48750(anonymous function) @ modules.js? 
hash=12bd683…:54194ZoneDelegate.invoke @ modules.js? 
hash=12bd683…:107413onInvoke @ modules.js? 
hash=12bd683…:54615ZoneDelegate.invoke @ modules.js? 
hash=12bd683…:107412Zone.run @ modules.js? 
hash=12bd683…:107306NgZoneImpl.runInner @ modules.js? 
hash=12bd683…:54646NgZone.run @ modules.js? 
hash=12bd683…:54538ApplicationRef_.run @ modules.js? 
hash=12bd683…:54183ApplicationRef_.bootstrap @ modules.js? 
hash=12bd683…:54205(anonymous function) @ modules.js? 
hash=12bd683…:53993(anonymous function) @ meteor.js? 
hash=ae8b8af…:1105ZoneDelegate.invoke @ modules.js? 
hash=12bd683…:107413onInvoke @ modules.js? 
hash=12bd683…:54615ZoneDelegate.invoke @ modules.js? 
hash=12bd683…:107412Zone.run 

... 

modules.js?hash=12bd683…:59337 TypeError: Cannot read property 'annotations' 
of undefined 
at RouteRegistry.configFromComponent (modules.js?hash=12bd683…:87825) 
at new RootRouter (modules.js?hash=12bd683…:87151) 
at routerFactory (modules.js?hash=12bd683…:89570) 
at ReflectiveInjector_._instantiate (modules.js?hash=12bd683…:50544) 
at ReflectiveInjector_._instantiateProvider (modules.js?hash=12bd683…:50473) 
at ReflectiveInjector_._new (modules.js?hash=12bd683…:50462) 
at ReflectiveInjectorDynamicStrategy.getObjByKeyId (modules.js?hash=12bd683…:50117) 
at ReflectiveInjector_._getByKeyDefault (modules.js?hash=12bd683…:50642) 
at ReflectiveInjector_._getByKey (modules.js?hash=12bd683…:50614) 
at ReflectiveInjector_.get (modules.js?hash=12bd683…:50423) 

如果我刪除@RouteConfig,則不會發生異常,但沒有顯示任何內容,因爲沒有內容需要顯示。任何想法可能會造成這種情況?

回答

0

經過一段時間的角度和流星的時間都用在撰寫時開箱的新版本上來。我也偶然發現瞭如何安裝軟件包。您可以使用以下格式:

meteor npm install @angular/core 

例如安裝角核心包

0

@RouterConfig僅適用於以前版本的路由器棄用和rc1。 隨着新版本3.0.0.apha.7其不再供貨。閱讀上的文檔在Routing & Navigation

使用示例是

export const DashboarRoutes = [ 
    { 
    path: 'dashboard', 
    component: DashboardComponent 
    }, 
    ... 
    e.t.c  
] 
export const routes: RouterConfig = [ 
...DashboardRoutes, 
...UIRoutes 
]; 

export const APP_ROUTER_PROVIDERS = [ 
    provideRouter(routes) 
]; 


APP_ROUTER_PROVIDERS is then passed when bootstrapping main application 
+0

我應該使用什麼命令來獲得所需要的新的包?嘗試了你的建議,但組件未解決 – mmelsen

+0

使用新的路由器3.0.0.apha.7,通過上面描述的設置,似乎組件正在返回未定義狀態。有任何想法嗎? – Colum

+0

是的,返回undefined。 – twilliams

相關問題