【发布时间】:2019-04-15 18:17:14
【问题描述】:
将import { FormsModule } from '@angular/core'; 添加到app.module.ts 文件后
我来了
Uncaught Error: Unexpected value 'undefined' imported by the module 'AppModule'
at syntaxError (compiler.js:2430)
at compiler.js:18651
at Array.forEach (<anonymous>)
at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (compiler.js:18620)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._loadModules (compiler.js:26029)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:26010)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler.compileModuleAsync (compiler.js:25970)
at CompilerImpl.push../node_modules/@angular/platform-browser-dynamic/fesm5/platform-browser-dynamic.js.CompilerImpl.compileModuleAsync (platform-browser-dynamic.js:143)
at compileNgModuleFactory__PRE_R3__ (core.js:17618)
at PlatformRef.push../node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModule (core.js:17801)
我请求社区帮助我。我是 Angular-7 的初学者
【问题讨论】:
-
你能分享更多代码吗?你在哪里使用
FormsModule? -
分享你的应用模块代码
-
从 '@angular/platform-browser' 导入 { BrowserModule };从'@angular/core'导入{ NgModule };从“@angular/core”导入 { FormsModule };从'./app.component'导入{AppComponent};从'./products/products.component'导入{ ProductComponent }; @NgModule({ 声明:[ AppComponent, BookComponent, ProductComponent, LowerPipe, DiscountPipe ], 进口: [BrowserModule,FormsModule ], 提供者: [],bootstrap: [AppComponent] }) 出口类 AppModule { }
-
嘿,我在这里分享了我的 app.module.ts 代码
-
我找到了答案。导入时出错。它是“@angular/forms”而不是“@angular/core”
标签: javascript angular typescript angularjs-directive