У меня есть шаблон, который выглядит следующим образом для component.html
<template>
<div>${someBoundProperty}</div>
<slot></slot>
</template>
Он должен использоваться следующим образом: app.html
:
<div>
<component some-bound-property="text here">
<component some-bound-property="more text"></component>
<component some-bound-property="and more text"></component>
</component>
</div>
, а вот component.ts
export class ComponentCustomElement {
@bindable someBoundProperty: string;
@children('component') subComponents: ComponentCustomeElement[] = []
}
Все до этого момента все работает как положено.Есть ли в aurelia способ добавить детей в мой массив во время выполнения в рамках моей модели представления, как показано ниже в component.ts
?:
attached() {
var newItem = new ComponentCustomElement();
newItem.someBoundProperty = "my custom text";
this.subComponents.push(newItem);
}
Конечно, добавление элемента в массив ничего не даствизуальная сторона.Есть ли способ построить представление и новую модель представления и передать его в Aurelia для обработки?