英文:
ng model is not working even after importing forms module in app.module.ts file?
问题
以下是要翻译的内容:
这是附加的截图,您可以看到FormsModule
被导入到app.module.ts
文件中,但错误仍未解决。
[![点击查看图片描述][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
[![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
],
})
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论