1. 程式人生 > >Angular: Can't bind to 'ngModel' since it isn't a known property of 'input'問題解決

Angular: Can't bind to 'ngModel' since it isn't a known property of 'input'問題解決

RM 雙向 input inpu 其中 blog tps react 解決辦法

https://blog.csdn.net/h363659487/article/details/78619225


最初使用

[(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 //此代碼僅為需加入的部分,註意比對你本身的代碼,把這個加入其中即可
]

Angular: Can't bind to 'ngModel' since it isn't a known property of 'input'問題解決