模型不起作用,即使在app.module.ts文件中导入了forms模块?

huangapple go评论58阅读模式
英文:

ng model is not working even after importing forms module in app.module.ts file?

问题

以下是要翻译的内容:

这是附加的截图,您可以看到FormsModule被导入到app.module.ts文件中,但错误仍未解决。

模型不起作用,即使在app.module.ts文件中导入了forms模块?

[![点击查看图片描述][2]][2]

这是登录组件,下面附带了截图
[2]: https://i.stack.imgur.com/Lcfq4.png

任何帮助将不胜感激,提前致谢。

英文:

Here is the attached screenshot where you can see that FormsModule is imported in app.module.ts file but still the error haven't resolved

模型不起作用,即使在app.module.ts文件中导入了forms模块?

[![enter image description here][2]][2]

Here is the login component and screenshot is posted given below
[2]: https://i.stack.imgur.com/Lcfq4.png

Any help would be appreciated and thanks in advance

答案1

得分: 1

打开 app.module.ts 文件,添加以下导入语句:

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

然后将 FormsModule 添加到 imports 中:

@NgModule({
  imports: [
    FormsModule
  ],
})

另外,我注意到你忘记声明 LoginComponent,请将其添加到 declarations 中:

@NgModule({
  declarations: [
    LoginComponent
  ],
})
英文:

Open app.module.ts and add the import line

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

And add FormsModule to imports

@NgModule({
  imports: [
    FormsModule
  ],
})

And i could see that you have forgot to declare your LoginComponent!

@NgModule({
  declarations: [
    LoginComponent
  ],
})

huangapple
  • 本文由 发表于 2023年2月14日 03:11:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75440276.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定