I've a simple component with a input for a string field:
import {Component, Input} from 'angular2/core';
@Component({
selector: 'mundo-input',
template: `
<input class="form-control" [(ngModel)]="zeit" />
`
})
export class MundoInputComponent {
@Input() zeit: string;
}
I am consuming this component like this:
<mundo-input [(zeit)]="myzeit"></mundo-input>
The myzeit-property from the outer component gets injected correctly. When I change the value by hand and press save on the outside component, the myzeit-property has the old value.
I changed the type of zeit from string to a Hero class (like in the NG2 Tutorial) and changed the binding of the input to zeit.name. The two-way databinding worked.
Is it possible to bind to a property of type string from the outer component? Or is it just possible with complex types (classes)?