为什么 (ngModel) 不起作用? [英] Why (ngModel) is not working?
本文介绍了为什么 (ngModel) 不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经运行示例应用程序来学习 angular 2.在我的示例应用程序中 [(ngModel)]
不起作用.但是当我删除方括号 (ngModel)
屏幕正在加载但双向绑定不起作用.
I have running the sample application to learn angular 2. In my sample application [(ngModel)]
is not working. But when i removes the square brackets (ngModel)
the screen is loading but two way binding is not working.
我应该做些什么让 [(ngModel)]
工作.
should i do anything for making [(ngModel)]
work.
推荐答案
可能你的代码在你的模块中缺少这个导入行:
Probably your code is missing this import line in your module:
import { FormsModule } from '@angular/forms';
您还必须将 FormsModule 添加到模块导入数组中:
You also have to add FormsModule to module imports array:
@NgModule({
imports: [FormsModule, /*...*/ ],
//...
})
这篇关于为什么 (ngModel) 不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文