Can't bind to 'ngModel' since it isn't a know property of the 'input' element and there are no matching directives with a corresponding property
Note: im using alpha.31
import { Component, View, bootstrap } from 'angular2/angular2'
@Component({
selector: 'data-bind'
})
@View({
template:`
<input id="name" type="text"
[ng-model]="name"
(ng-model)="name = $event" />
{{ name }}
`
})
class DataBinding {
name: string;
constructor(){
this.name = 'Jose';
}
}
bootstrap(DataBinding);
Best Answer
Angular has released its final version on 15th of September. Unlike Angular 1 you can use
ngModel
directive in Angular 2 for two way data binding, but you need write it in a bit different way like[(ngModel)]
(Banana in a box syntax). Almost all angular2 core directives doesn't supportkebab-case
now instead you should usecamelCase
.app/app.component.ts
app/app.module.ts
app/main.ts
Demo Plunkr