我遇到TypeError:无法读取属性'注释'当我将我的应用程序更新为rc1时出现未定义的错误。知道什么会导致这个问题吗? 我应该使用而不是' @ angular / router-deprecated' ' @角/路由器' ?
import {Component, provide, Optional, Inject, NgZone} from '@angular/core';
import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from '@angular/router-deprecated';
import {CliRouteConfig} from './route-config';
//import * as Redux from 'redux';
import {RegisterSimple} from './register-simple/register-simple';
import {Register} from './register/register';
@Component({
selector: 'account-app',
providers: [],
template: `
<h2>Account</h2>
<nav>
<a [routerLink]="['RegisterSimple']" class="nav-register-simple">Register Simple</a>
<a [routerLink]="['Register']" class="nav-register">Register</a>
</nav>
<hr>
<div style="margin:20px; border:1px solid #ccc;">
<router-outlet></router-outlet>
</div>
`,
directives: [ROUTER_DIRECTIVES, RegisterSimple],
pipes: []
})
@RouteConfig([
{ path: '/register-simple', name: 'RegisterSimple', component: RegisterSimple },
{ path: '/register', name: 'Register', component: Register },
].concat(CliRouteConfig))
export class AccountApp {
private userState: any = null;
constructor(
private ngZone: NgZone,
@Optional() @Inject('UserStore') UserStore: any
) {
let userData = {
general: {
userNodeID: 123,
username: 'Max.m',
firstname: 'Max',
lastname: 'Mustermann',
salutation: 'Mr',
birthdate: '23.12.1988'
},
address: {
street: 'Musterstraße',
houseNumber: '4',
postCode: '4020',
city: 'Linz',
countryCode: 'AT'
},
contact: {
phone: '0123456789',
email: 'max@mustermann.at',
newsletter: true
},
payment: {
accountHolderName: 'Max Mustermann',
bic: 'AT65232323',
iban: 'AT9837272727272'
},
culture: {
currency: 'EUR',
language: 'de',
oddFormat: 'Decimal'
}
}
this.ngZone.runOutsideAngular(() => {
this.ngZone.run(() => {
});
});
}
}
Main.ts
import { bootstrap } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AccountApp, environment} from './app';
if (environment.production) {
enableProdMode();
}
bootstrap(AccountApp);
错误消息
EXCEPTION: Error in :0:0
browser_adapter.ts:78 EXCEPTION: Error in :0:0BrowserDomAdapter.logError @ browser_adapter.ts:78
browser_adapter.ts:78 ORIGINAL EXCEPTION: TypeError: Cannot read property 'annotations' of undefinedBrowserDomAdapter.logError @ browser_adapter.ts:78
browser_adapter.ts:78 ORIGINAL STACKTRACE:BrowserDomAdapter.logError @ browser_adapter.ts:78
browser_adapter.ts:78 TypeError: Cannot read property 'annotations' of undefined
at RouteRegistry.configFromComponent (route_registry.ts:112)
at new RootRouter (router.ts:522)
at routerFactory (router_providers_common.ts:31)
at DebugAppView.get (AccountApp_Host.template.js:55)
at DebugAppView._View_AccountApp_Host0.injectorGetInternal (AccountApp_Host.template.js:95)
at DebugAppView.AppView.injectorGet (view.ts:145)
at DebugAppView.injectorGet (view.ts:325)
at ElementInjector.get (element_injector.ts:16)
at DebugAppView._View_AccountApp0.createInternal (AccountApp.template.js:60)
at DebugAppView.AppView.create (view.ts:110)BrowserDomAdapter.logError @ browser_adapter.ts:78
browser_adapter.ts:78 ERROR CONTEXT:BrowserDomAdapter.logError @ browser_adapter.ts:78
browser_adapter.ts:78 DebugContext
答案 0 :(得分:1)
它看起来像角度错误/版本不兼容。尝试运行npm install,检查systemjs config,package.json,交换路由器版本。
答案 1 :(得分:1)
我有同样的错误消息。这是因为我试图用rc.4运行大多数软件包(普通软件,核心软件等),并且仍然在rc.1(发布时的最新版本)上有路由器。将其他软件包移回rc.1解决了这个问题。