admin管理员组文章数量:1376572
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'?
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'?
Share Improve this question edited Oct 12, 2016 at 22:36 Jeremy Danyow 26.4k12 gold badges90 silver badges135 bronze badges asked Mar 23, 2016 at 4:55 VaccanoVaccano 82.7k161 gold badges502 silver badges918 bronze badges1 Answer
Reset to default 13This is a scenario that's part of the test suite. Should look something like this:
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>
Tests
You must update to the 3/1/2016 version of Aurelia to use this http://blog.durandal.io/2016/03/01/aurelia-early-march-2016-update/
本文标签: javascriptCan Aurelia39s quotrepeatforquot be used with quotviewmodelrefquotStack Overflow
版权声明:本文标题:javascript - Can Aurelia's "repeat.for" be used with "view-model.ref" - Stack Overfl 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744004587a2574466.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论