【问题标题】:compiler.js:2430 Uncaught Error: Unexpected value 'undefined' imported by the module 'AppModule' [duplicate]compiler.js:2430 未捕获的错误:模块“AppModule”导入的意外值“未定义”[重复]
【发布时间】: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-b​​rowser' 导入 { 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


【解决方案1】:

试试这个

import { FormsModule } from '@angular/forms';

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-21
    • 2019-09-12
    • 2018-06-06
    • 2017-01-08
    • 2018-10-10
    • 2019-04-22
    • 2020-05-30
    • 2018-01-31
    相关资源
    最近更新 更多