Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why (ngModel) is not working?

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.

like image 692
ganku007 Avatar asked Mar 09 '23 02:03

ganku007


1 Answers

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, /*...*/ ],
   //...
})
like image 83
Marius Orha Avatar answered Mar 21 '23 09:03

Marius Orha