I'm trying to learn the basics of Angular2, so I was trying to make some tests. I've already downloaded typescript
and angular/cli
.
I can use iterpolation, property binding, etc. but when I try to use a two-way data-binding like that(in app.component.html
for tests):
<input type="text" [(ngModel)]="test.description">
and the ng server
refreshes, all the things that I've done disappear and all I see is a blank screen.
I ask that the answers be simple, because I'm a begginner in using angular.
EDIT:
Even after updating app.modules.ts
, my console keep displaying the following error:
Uncaught Error: Template parse errors:
Can't bind to 'NgModel' since it isn't a known property of 'input'. ("
</p>
<input type="text" [ERROR ->][(NgModel)]="test.description" >`
You must be getting an error on console, to use ngModel
, Add this to your Module,
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@NgModule({
imports: [
FormsModule
]
Use the correct syntax ngModel
<input type="text" name="name" [(ngModel)]="test.description">