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

I have repeat.forin a user element in my view (giving me a list of UI elements):

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

I would like my view model to have a list of custom item models (so I can call validation methods for 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 property boxViewModelsdoes not add anything to the array. I even tried to see if it would even bind inside repeat.for:

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

But after I created several instances, boxViewModelTestingthere is undefined.

It makes me wonder if it will view-model.refwork inside repeat.for.

- , 'repeat.for'?

+4
1

, . :

export class Foo {
  boxElements = [];
  boxViewModels = [];
  boxViews = [];
  boxControllers = [];
}
<template>
  <div repeat.for="box of boxes">
    <box ref="boxElements[$index]"
         view-model.ref="boxViewModels[$index]"
         view.ref="boxViews[$index]"     
         controller.ref="boxControllers[$index]">
    </box>
  </div>
</template>

Aurelia 3/1/2016, http://blog.durandal.io/2016/03/01/aurelia-early-march-2016-update/

+10

All Articles