クラスのプロパティに@bindable
デコレータを使用することに問題はありません。 など。getterとsetterを持つプロパティでAureliaのバインディング可能なデコレータを使用する方法
export class SomeClass {
@bindable public SomeProperty: Date = new Date();
}
しかし、getter/setterの実装を持つプロパティで使用すると、私は困惑します。例えば。
私はここに簡単な何かが欠けていると確信しているexport class SomeClass2 {
// Where should the @bindable go now?
private _someProperty: Date = new Date();
public get SomeProperty(): Date {
return this._someProperty;
}
public set SomeProperty(value: Date) {
// Do some manipulation/validation here
this._someProperty = value;
}
}
...
ああ、OK - 実際にgetter/setterを作成している '@ bindable 'についてのキーはキーです - それを拾いませんでした - ありがとう!上記を見ると、実際には2つの変数( 'name'と' _name')がありません。変更されたカスケードだけを '_name'変数に制御する' Changed'メソッドがあります。あるいは '@ bindable'は' _name'が 'name'の裏付けであることを認識するために" magic/convention "を持っていますか? – Jaans