私はこのようにレイアウトしたカスタム要素をいくつか持っています。私は@childrenデコレータが私にコマンドラインビューモデルで適切に 'items'配列を与えていることがわかりました.2つの行ボタンのサイズ(期待通り)を持っています。Aurelia @孫の飾り孫が孫の要素のために働いていない
私が見ている問題は、行ボタンのビューモデルの@children 'buttons'配列にあります。それは常に0のサイズです!誰かが私に間違っていることを教えてもらえますか?
<command-panel label="Test" icon="fa-shield">
<row-button row-title="Row1">
<command-button btn-name="Force"></command-button>
</row-button>
<row-button row-title="Row2">
<command-button btn-name="Test"></command-button>
</row-button>
</command-panel>
コマンドpanel.ts
import {bindable, children} from 'aurelia-framework';
export class CommandPanel {
@bindable label;
@bindable icon;
@children('row-button') items = [];
bind(bindContext) {
console.log(this.items);
}
}
行button.ts
import {bindable, children} from 'aurelia-framework';
export class RowButton {
@bindable rowTitle;
@bindable icon;
@children('command-button') buttons = [];
selectedItem = null;
constructor() {
console.log(this.buttons);
}
}
コマンドbutton.ts
import {bindable} from 'aurelia-framework';
export class CommandButton {
@bindable btnName;
btnNameChanged(newValue) {
console.log("label is " + this.btnName);
}
}