问题
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