It is possible to pass attributes to Aurelia custom element with @bindable
decorator:
export class ItemCustomElement {
@bindable model: Item;
}
<item model.bind="model"></item>
Why custom elements rendered by <compose>
are treated differently, according to docs they need an activate
method to pass data? @bindable
is not respected.
export class ItemCustomElement {
@bindable model: Item;
activate(model: Item): void {
this.model = model;
}
}
<compose view-model="./item" model.bind="model"></compose>
From the custom element's point of view, currently it needs to know how it is going to be used, with <compose>
or not. I think a custom element should be isolated from this external decision. Can we make @bindable
work in both cases?