错误:

Can’t bind to ‘ngModel’ since it isn’t a known property of ‘input’

原因:

html代码中出现类似这样的<input type=“text” [(ngModel)]=“username”>语句,其中使用了[(ngModel)]。

在AngularJS2或以上版本中使用了NgModel指令,必须在app.module.ts文件中导入FormsModule模块。

解决:

1 . 在app.module.ts文件导入语句中添加import { FormsModule } from ‘@angular/forms’;

2 . 修改app.module.ts文件import[]部分

1 import:[
2     xxxx,
3     FormsModule,  //这个地方必须添加
4     xxxx
5 ]

 

 

相关文章:

  • 2021-06-05
  • 2021-12-04
  • 2021-05-24
  • 2021-07-21
  • 2021-09-06
  • 2021-10-09
  • 2022-12-23
猜你喜欢
  • 2021-04-16
  • 2021-07-14
  • 2022-12-23
  • 2021-04-20
  • 2021-06-15
  • 2021-04-25
  • 2022-12-23
相关资源
相似解决方案