使用 routeconfig 时无法读取未定义的 属性 'annotations'
Cannot read property 'annotations' of undefined when using routeconfig
我正在使用社交应用教程来学习 Angular2 and Meteor。我遇到了一个找不到根本原因的问题。
我正在关注 tutorial 声明要添加:
RouteConfig
注解:
@RouteConfig([
{
path: '/',
as: 'PartiesList',
component: PartiesList
}, {
path: '/party/:partyId',
as: 'PartyDetails',
component: PartyDetails
}
]);
router-outlet
在 app.html:
<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
则不会发生异常,但不会明显显示任何内容,因为没有内容可以显示。知道是什么原因造成的吗?
@RouterConfig 仅适用于旧版本的路由器 deprecated 和 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
一段时间后,angular 和 meteor time 推出了新版本,在撰写本文时开箱即用。我也偶然想出了如何安装一个包。您可以使用以下格式:
meteor npm install @angular/core
例如安装angular核心包
我正在使用社交应用教程来学习 Angular2 and Meteor。我遇到了一个找不到根本原因的问题。
我正在关注 tutorial 声明要添加:
RouteConfig
注解:
@RouteConfig([
{
path: '/',
as: 'PartiesList',
component: PartiesList
}, {
path: '/party/:partyId',
as: 'PartyDetails',
component: PartyDetails
}
]);
router-outlet
在 app.html:
<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
则不会发生异常,但不会明显显示任何内容,因为没有内容可以显示。知道是什么原因造成的吗?
@RouterConfig 仅适用于旧版本的路由器 deprecated 和 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
一段时间后,angular 和 meteor time 推出了新版本,在撰写本文时开箱即用。我也偶然想出了如何安装一个包。您可以使用以下格式:
meteor npm install @angular/core
例如安装angular核心包