I want to call a child component from a parent. I have a way to do this, but I want to know if there is not a better way.
From Ashley Grant 's blog post about accessing a custom viewModel from a custom attribute, I see that Aurelia adds auto the element and you can access the viewModel through this. So, if I add a nested component with ref, like this:
<template>
<nested-element ref="childElement"></nested-element>
</template>
I can call the function on it as follows:
this.childElement.au.controller.viewModel.someFunction();
That's cool. I was hoping that I would be able to access the nested viewModel using the parameters to the hook that implements the parent, for example created(owningView, myView), but I cannot find the path to it.
Did I miss the best way?
: , , , view