2019年5月7日 星期二

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'

這時要檢查 app.module.ts ,看看是否 import 了 FormsModule




官網上提到,當使用到雙向繫結關鍵字  [(ngModel)] 卻沒引用 FormsModule ,就會出現錯誤:
Can't bind to 'ngModel' since it isn't a known property of 'input'.

沒有留言:

張貼留言