を働いていない:私はこのように、このコンポーネントを消費しています角度2 Modelbinding(文字列)を単純ために、私は文字列フィールドの入力との単純なコンポーネントまし
import {Component, Input} from 'angular2/core';
@Component({
selector: 'mundo-input',
template: `
<input class="form-control" [(ngModel)]="zeit" />
`
})
export class MundoInputComponent {
@Input() zeit: string;
}
を:
<mundo-input [(zeit)]="myzeit"></mundo-input>
外部コンポーネントからのmyzeit-propertyが正しく注入されます。値を手動で変更して外部コンポーネントのsaveを押すと、myzeit-propertyは古い値を持ちます。
私はzeitのタイプをstringからHeroクラス(NG2チュートリアルのように)に変更し、入力のバインディングをzeit.nameに変更しました。双方向のデータバインディングが機能しました。
文字列型のプロパティに外部コンポーネントからバインドすることはできますか?複雑な型(クラス)で単なる可能性はありますか?
http://stackoverflow.com/questions/36320605/angular-2-component-modelbinding-is-not-working/36338106#36338106との違いは何ですか? –
最初にリンクした質問を編集しましたが、別の質問 – Weissvonnix