问题1:
- 在input中使用[ngModel]报错:
`Can't bind to 'ngModel' since it isn't a known property of 'input'`
解决办法:
- 在module.ts中添加import
- import { NgModule } from ‘@angular/core’;
- import { FormsModule } from ‘@angular/forms’;
问题2
Can't bind to 'formControl' since it isn't a known property of 'input'.
解决办法
模块中注入
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
组件中注入:
import { FormControl } from '@angular/forms';
本文详细介绍了在Angular2中解决input绑定ngModel及formControl时遇到的常见错误。针对`Can't bind to 'ngModel' since it isn't a known property of 'input'`及`Can't bind to 'formControl' since it isn't a known property of 'input'`问题,提供了具体的解决方案,包括在module.ts中正确导入FormsModule和ReactiveFormsModule,并在组件中导入FormControl。
4395

被折叠的 条评论
为什么被折叠?



