Nicht abgefangene Fehler: Unerwarteter Richtlinie "MyComboBox" importiert durch das Modul 'AppModule'. Fügen Sie bitte ein @NgModule annotation
Habe ich eine benutzerdefinierte Komponente (MyComboBox), die kendo-combobox-innen.
Wenn ich mit meinem core-Modul, webpack Zusammenstellung endet erfolgreich, aber chrome wirft die folgende Fehlermeldung:
Uncaught Error: Unexpected directive 'MyComboBox' imported by the module 'AppModule'. Please add a @NgModule annotation.
at syntaxError (eval at <anonymous> (http://localhost:8086/vendor.js:1354:1), <anonymous>:1682:34) [<root>]
at eval (eval at <anonymous> (http://localhost:8086/vendor.js:1354:1), <anonymous>:14149:44) [<root>]
at Array.forEach (native) [<root>]
at CompileMetadataResolver.getNgModuleMetadata (eval at <anonymous> (http://localhost:8086/vendor.js:1354:1), <anonymous>:14132:49) [<root>]
at JitCompiler._loadModules (eval at <anonymous> (http://localhost:8086/vendor.js:1354:1), <anonymous>:25313:64) [<root>]
at JitCompiler._compileModuleAndComponents (eval at <anonymous> (http://localhost:8086/vendor.js:1354:1), <anonymous>:25272:52) [<root>]
at JitCompiler.compileModuleAsync (eval at <anonymous> (http://localhost:8086/vendor.js:1354:1), <anonymous>:25234:21) [<root>]
at PlatformRef_._bootstrapModuleWithZone (eval at <anonymous> (http://localhost:8086/vendor.js:16:1), <anonymous>:4992:25) [<root>]
at PlatformRef_.bootstrapModule (eval at <anonymous> (http://localhost:8086/vendor.js:16:1), <anonymous>:4978:21) [<root>]
at eval (eval at <anonymous> (http://localhost:8086/app.js:4275:1), <anonymous>:10:53) [<root>]
at Object.<anonymous> (http://localhost:8086/app.js:4275:1) [<root>]
at __webpack_require__ (http://localhost:8086/polyfills.js:53:30) [<root>]
at Object.<anonymous> (http://localhost:8086/app.js:8253:18) [<root>]
at __webpack_require__ (http://localhost:8086/polyfills.js:53:30) [<root>]
ZoneAwareError @ zone.js?fad3:917
syntaxError @ VM3491:1682
(anonymous) @ VM3491:14149
CompileMetadataResolver.getNgModuleMetadata @ VM3491:14132
JitCompiler._loadModules @ VM3491:25313
JitCompiler._compileModuleAndComponents @ VM3491:25272
JitCompiler.compileModuleAsync @ VM3491:25234
PlatformRef_._bootstrapModuleWithZone @ core.es5.js?0445:4992
PlatformRef_.bootstrapModule @ core.es5.js?0445:4978
(anonymous) @ main.ts?5861:11
(anonymous) @ app.js:4275
__webpack_require__ @ polyfills.js:53
(anonymous) @ app.js:8253
__webpack_require__ @ polyfills.js:53
webpackJsonpCallback @ polyfills.js:24
(anonymous) @ app.js:1
Hier ist mein AppModule:
app.- Modul.ts
import { MyComboBox } from '@my/core/control/MyComboBox';
@NgModule({
declarations: [
AppComponent,
MyComboBox
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
DragulaModule,
MyComboBox,
CoreModule,
ComboBoxModule
],
entryComponents: [ MyComboBox ],
//viewProviders: [ DragulaService ],
providers: [HelperService],
bootstrap: [AppComponent]
})
Sollten Sie den Import-Core-Modul statt
import { ComboBoxModule } '@progress/kendo-angular-dropdowns';
Meine Frage war, wo haben Sie den export
import { ComboBoxModule } '@progress/kendo-angular-dropdowns'; import { ... MyComboBox, ... } ... @NgModule({ Importe: [ ... ComboBoxModule, ... ], ... exportiert: [ ... MyComboBox, ... ] Erklärungen: [ ... MyComboBox, ... ],
Es ist mein core-Modul.
MyComboBox
. Können Sie zeigen, wie Sie exportiert haben, und erklärt MyComboBox
?import { ComboBoxModule } '@progress/kendo-angular-dropdowns';
Meine Frage war, wo haben Sie den export
MyComboBox
? Ich meine, in welchem Modul? Können Sie das bitte zeigen.import { ComboBoxModule } '@progress/kendo-angular-dropdowns'; import { ... MyComboBox, ... } ... @NgModule({ Importe: [ ... ComboBoxModule, ... ], ... exportiert: [ ... MyComboBox, ... ] Erklärungen: [ ... MyComboBox, ... ],
Es ist mein core-Modul.
InformationsquelleAutor Hamit | 2017-04-25
Du musst angemeldet sein, um einen Kommentar abzugeben.
BEARBEITEN :
Dieser Fehler Häufig auftaucht, wenn wir nicht
importing
,providing
oderdeclaring
den eckigenmodules
,services
,components
richtig.Stellen Sie sicher, dass, sollten wir nur
modules
und nicht diecomponents
oderservices
components
und nicht diemodules
oderservices
.services
und nichtcomponents
odermodules
.Original Antwort :
Du nicht wirklich importieren
MyComboBox
in eurem App-Modul. Da Sie bereits exportiert es inCoreModule
. Also ich würde vorschlagen, Sie zu entfernenMyComboBox
aus Ihre Importe array inAppModule
. ImportierenCoreModule
geben SieMyComboBox
Komponente innerhalbAppModule
.app.- Modul.ts
Hinweis : Sie können die import-Komponente frei, wie Sie es tun. Es muss enthalten sein in das Modul importiert werden.
Dies ist, weil ich mit kendo ist GridModule in meine custom MyDataGrid
Meine core-Modul wieder: import { GridModule } '@progress/kendo-angular-raster'; ... @NgModule({ Importe: [ ... GridModule, ButtonsModule, ComboBoxModule, InputsModule, DropDownsModule, UploadModule, LayoutModule, DialogModule ], ....
Es scheint einige problem mit kendo-Paket dann. Stellen Sie sicher, dass Sie die richtige version von kendo und eckig-cli, die erforderlich ist, um zu laufen.
von Ihnen positiv bewertet werden für die Erklärung.
InformationsquelleAutor Amit Chigadani
In meinem Fall, ich war irrtümlich in der Liste die Komponente in der
imports: []
array, die, wohlgemerkt, es erwartet, dass Module, die keine Komponenten sind, und das ist der Grund, Eckig, klagte er konnte nicht finden, dass die@NgModule
definition.Statt, die ich brauchte, um die Liste der Komponenten in der
declarations: []
Liste. 🙂Ja, ich auch verpasst. Ich habe versehentlich meine Komponenten in der Einfuhr:[]
Froh, dass ich helfen konnte! 😀
InformationsquelleAutor Samer s Salib