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

来源:互联网 发布:淘宝店的货源哪里来 编辑:程序博客网 时间:2024/06/05 15:13

当使用

[(ngModel)]

做双向绑定时,如果遇见Angular: Can’t bind to ‘ngModel’ since it isn’t a known property of ‘input’问题
解决办法:
在你的app.module中添加如下代码即可:
import { FormsModule, ReactiveFormsModule } from ‘@angular/forms’;

@NgModule({
imports: [
FormsModule //此代码仅为需加入的部分,注意比对你本身的代码,把这个加入其中即可
]

阅读全文
0 0