美文网首页我爱编程
Angular双向数据绑定问题

Angular双向数据绑定问题

作者: 徐启明 | 来源:发表于2018-04-15 07:01 被阅读0次

使用【(ngModel)】时候报错:

1. core.js:1448 ERROR Error: Uncaught (in promise): Error: Template parse errors: Can't bind to 'ngModel' since it isn't a known property of 'input'.

解决: 在此compoent对应的model文件中 

import { FormsModule } from '@angular/forms'; // <-- NgModel lives here

并在@NgModule 中的imports: 中添加FormsModule

2. ERROR Error: If ngModel is used within a form tag, either the name attribute must be set or the form control must be defined as 'standalone' in ngModelOptions。

解决: 在html文件对应的input框中添加unique name属性

相关文章

网友评论

    本文标题:Angular双向数据绑定问题

    本文链接:https://www.haomeiwen.com/subject/whzrkftx.html