Reputation: 77
So I'm a newbie on Angular2(javascript) and I was able to make a simple "Hello world" with the angular 5 min tutorial. And I was curious of the new changes on Angular2 I start reading the Angular2 Js docs but I found that it was incomplete(sucks), so I started playing around, and I got stuck on two way binding. It always returns undefined
My current script:
( function(app) {
app.TestComponent =
ng.core.Component({
selector: 'test-comp',
template: '<input ([ngModel])="name"><input type="button" (click)="click()" value="click">'
}).Class({
constructor: function(){},
click: function(){ console.log(this.name) }
})
})
(function(app) {
app.AppModule =
ng.core.NgModule({
imports: [
ng.platformBrowser.BrowserModule
],
declarations: [ app.TestComponent ],
bootstrap: [ app.TestComponent ]
})
.Class({
constructor: function() {}
});
})(window.app || ( window.app = {} ));
Whats puzzling me is there are no errors. Which makes it more difficult to Identify whats causing the undefined. Help!
Upvotes: 2
Views: 662
Reputation: 658057
It has to be
[(ngModel)]
not
([ngModel])
It's called banana in a box for a reason ;-)
Upvotes: 2