If there is a parent component and a child, is there a way to trigger an event in the child component without checking the whole component tree.
import { Component } from '@angular/core'
@Component({
selector: 'my-app',
template: '<b>{{ text() }}</b><br /><app-child></app-child>'
})
export class AppComponent {
text() {
console.log('parent')
return 'parent'
}
}
@Component({
selector: 'app-child',
template: '<b>{{ text() }}</b><span (click)="change()"> | Change</span>'
})
export class ChildComponent {
text() {
console.log('child')
return 'child'
}
change() { }
}
Here, i want that when the change method is called in the child component, that the parent component does not have to check the view (just logging "child" instead of "parent" and "child").