Why (ngModel) is not working?

*爱你&永不变心* 提交于 2019-12-20 01:09:44

问题


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.

should i do anything for making [(ngModel)] work.


回答1:


Probably your code is missing this import line in your module:

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

You also have to add FormsModule to module imports array:

@NgModule({
   imports:      [FormsModule, /*...*/ ],
   //...
})


来源:https://stackoverflow.com/questions/43994919/why-ngmodel-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!