I'm sorry if it's already in the book, I haven't seen it.
The scenario is: you need the parent view-model instance in the child view-model.
This is done by the Aurelia's DI magic which looks up in the DI containment hierarchy and gets the parent VM instance.
I think it would be very helpful to talk in the book about Aurelia's DI containment hierarchy, how it works, how is Aurelia building the hierarchy, etc. And also maybe some advanced stuff like, how to change the default DI hierarchy if needed (I don't have an example yet).
import {inject} from 'aurelia-framework';
import {Parent} from './parent'
@inject(Parent)
export class Child {
constructor(parent) {
this.parent = parent;
console.log("hello from child, parent's name is", this.parent.name);
}
}
I'm sorry if it's already in the book, I haven't seen it.
The scenario is: you need the parent view-model instance in the child view-model. This is done by the Aurelia's DI magic which looks up in the DI containment hierarchy and gets the parent VM instance. I think it would be very helpful to talk in the book about Aurelia's DI containment hierarchy, how it works, how is Aurelia building the hierarchy, etc. And also maybe some advanced stuff like, how to change the default DI hierarchy if needed (I don't have an example yet).