Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access composed children?

Tags:

aurelia

I have a list of composed elements:

<compose repeat.for="foo of someList" view-model="./bar" model.bind="foo">

Now, from the parent, I would like to call a function on a specific bar view model. How do I do that?

like image 301
jgillich Avatar asked Jan 30 '26 20:01

jgillich


1 Answers

You can add view-model.ref in your compose tag:

<compose repeat.for="foo of someList" view-model="./bar" model.bind="foo" view-model.ref="foo.barviewmodel">

You can replace view-model.ref by compose.ref. The both give the same result.

And in the parent you can call a function on a bar view model like this:

this.someList[2].barviewmodel.currentViewModel.action();

It works, but I don't know if it's a public api. See this issue for more details

like image 124
Valentin B. Avatar answered Feb 01 '26 13:02

Valentin B.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!