Thanks for your answer, but it’s not exactly what I am looking for. So in your example the only thing that get bound into the child view is a function. I would like to know if its possible to allow the html only child to have access to the parent view model (included all methods and properties).
Curious, why do we need to call $this .$parent rather than just $parent? DynamicElement seems to be the implicit viewmodel of the view, so since $parent is a property, should this not always be available? When do and when dont we need to explicitly use $this? Thanks!
In short, it’s an naming choice that was aimed for consistency, but unfortunately confusing.
Normally in Aurelia, an expression starting with $parent in template makes Aurelia binding goes up 1 “level”, in term of scope. This is generally used in repeat/with blocks. Custom element does not have a parent scope that can be traversed normally with $parent.
To compare: $parent.handleChildClick() means: walk up 1 level of scope (nothing), and call handleChildClick() $this.$parent.handleChildClick() means: get current scope ($this), access property $parent and then call handleChildClick on that.