Ich benutze Angular2 und ich habe dieses Problem beim Versuch, zwei Klassen in der gleichen Typoskript-Datei zu verwenden.Unerwarteter Wert 'AnyComponent' vom Modul 'AppModule'
Beim Kompilieren nicht geben Sie mir einen Fehler, aber wenn ich versuche, die Seite der console.log schenkt diesen Fehler auszuführen:
Error: [email protected]://www.my.app/panel-module/node_modules/@angular/compiler//bundles/compiler.umd.js:5116:27
CompileMetadataResolver</CompileMetadataResolver.prototype.getNgModuleMetadata/<@http://www.my.app/panel-module/node_modules/@angular/compiler//bundles/compiler.umd.js:13274:35
CompileMetadataResolver</[email protected]://www.my.app/panel-module/node_modules/@angular/compiler//bundles/compiler.umd.js:13261:21
RuntimeCompiler</[email protected]://www.my.app/panel-module/node_modules/@angular/compiler//bundles/compiler.umd.js:15845:28
RuntimeCompiler</[email protected]://www.my.app/panel-module/node_modules/@angular/compiler//bundles/compiler.umd.js:15769:36
RuntimeCompiler</[email protected]://www.my.app/panel-module/node_modules/@angular/compiler//bundles/compiler.umd.js:15746:20
PlatformRef_</[email protected]://www.my.app/panel-module/node_modules/@angular/core//bundles/core.umd.js:9991:20
PlatformRef_</[email protected]://www.my.app/panel-module/node_modules/@angular/core//bundles/core.umd.js:9984:20
@http://www.my.app/panel-module/app/main.js:4:1
@http://www.my.app/panel-module/app/main.js:1:31
@http://www.my.app/panel-module/app/main.js:1:2
Zone</ZoneDelegate</[email protected]://www.my.app/panel-module/node_modules/zone.js/dist/zone.js:332:20
Zone</Zone</[email protected]://www.my.app/panel-module/node_modules/zone.js/dist/zone.js:225:25
scheduleResolveOrReject/<@http://www.my.app/panel-module/node_modules/zone.js/dist/zone.js:586:53
Zone</ZoneDelegate</[email protected]://www.my.app/panel-module/node_modules/zone.js/dist/zone.js:365:24
Zone</Zone</[email protected]://www.my.app/panel-module/node_modules/zone.js/dist/zone.js:265:29
[email protected]://www.my.app/panel-module/node_modules/zone.js/dist/zone.js:491:26
F/</g[email protected]://www.my.app/panel-module/node_modules/core-js/client/shim.min.js:8:10016
F/<@http://www.my.app/panel-module/node_modules/core-js/client/shim.min.js:8:10138
a.exports/[email protected]://www.my.app/panel-module/node_modules/core-js/client/shim.min.js:8:14293
Evaluating http://www.my.app/panel-module/app/main.js
Error loading http://www.my.app/panel-module/app/main.js
Unten ist meine Komponente Typoskript-Datei.
// MyComponent.ts
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: '/path/to/view',
})
export class MyObject {
id: number;
}
export class MyComponent {
obj: MyObject;
// unecessary code
}
Danke, ich auf der anderen Seite behoben, aber ich wusste nicht, warum ich das tun musste. –
, weil der 'Decorator @ Component' vor Ihrer Komponente sein muss. Ohne diesen Dekorator ist Ihre Komponente keine echte Komponente. Ansonsten ist es nur eine Klasse. – mxii
danke, also sollte die Komponente zuerst definiert werden, bevor sie im Modul verwendet wird. –