Can Aurelia's "repeat.for" be used with "view-model.ref"

Viewed 2033

I have a repeat.for on a custom element in my view (giving me a list if UI elements):

<box repeat.for="box of boxes" box.bind="box"></box>

I would like my view-model to have a list of the of the custom element's view-models (So I can call validate methods on each of the items in my list.)

I tried this:

<div repeat.for="box of boxes">
    <box box.bind="box" view-model.ref="boxViewModels[${$index}]"></box>
</div>

But the boxViewModels property does not get anything added to the array. I even tried to see if it would bind at all inside of the repeat.for:

<div repeat.for="box of boxes">
    <box box.bind="box" view-model.ref="boxViewModelTesting"></box>
</div>

But after I created a few instances, boxViewModelTesting is undefined.

Makes me wonder if view-model.ref just will not work inside a repeat.for.

Is there any way to get the references of view-models of custom attributes created with a 'repeat.for'?

1 Answers
Related