@timfish mentioned in this discussion that
Aurelia automatically checks parent view-models when its binding to properties and methods
I am not seeing this behaviour, at least, it doesn’t seem to traverse all the way to the root. I am trying to build the React Tic-Tac-Toe tutorial in Aurelia as a contrast and compare exercise and have managed for the most part but eventually there’s a point where all the state is managed at the ‘game’ level and is passed down through the ‘board’ component to the ‘square’ component. So far I can pass values using the bindable attributes but accessing methods is proving challenging
It’s only check when the view models are connected. In the following example
1. in here is a "view model", the App instance
<div repeat.for="item of items">
2. there is view model here created by Aurelia for each repeated item.
And whatever expression here will also take app instance view model (aka parent vm)
That’s the common scenario where you see Aurelia looks in parent view model for something. There’s another case where you can connect the view models yourself, via setting a special property on the metadata, named “inheritBindingContext”. We had another thread related to it here Question on why inheritBindingContext is off for normal component, but on for dynamically composed component
Would be great if @timfish can help clarify what he had in mind
inheritBindingContext was exactly what I needed, thanks!
I honestly have no idea what I had in mind as that discussion was years ago!