Angular中提示:Can't bind to 'ngModel' since it isn't a known property of 'input'

场景

在Angular项目中使用[(ngModel)]双向数据绑定时提示:

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

注:

博客:
https://blog.csdn.net/badao_liumang_qizhi
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。

解决

这是因为在使用双向数据绑定[(ngModel)]时必须引入FormsModule这个模块。

打开app.module.ts

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

并添加声明

原文地址:https://www.cnblogs.com/badaoliumangqizhi/p/12797246.html