While it's common to send data from a parent component to a child using @Input or call a method on the parent component from the child using @Output, I am interested in doing the opposite - calling a method on the child from the parent. Here is an example of what I have in mind:
@Component({
selector: 'parent',
directives: [Child],
template: `
<child
[fn]="parentFn"
></child>
`
})
class Parent {
constructor() {
this.parentFn()
}
parentFn() {
console.log('Parent triggering')
}
}
And for the child component:
@Component({
selector: 'child',
template: `...`
})
class Child {
@Input()
fn() {
console.log('triggered from the parent')
}
constructor() {}
}
The scenario here is like making a "get" request to get updated status information from the child component.
I understand that achieving this through a service and Subject/Observable is possible, but I'm curious if there's a more direct approach available.