I have an app where I have an upload component where I can upload a file. It is embedded in the body.component
.
On upload, it should use a function (e.g.
You can inject the parent component to the child component.
For more details see
- How do I inject a parent component into a child component?
- Angular 2 child component refers to parent component
This way you can ensure that thefunction()
is only called when parent is a body.component
.
constructor(@Host() bodyComp: BodyComponent) {
Otherwise using @Output()
is preferred to communicate from child to parent.