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").
(scroll)="").NavigationEndso that would be expected behavior. Instead maybe attach an event listener directly to the dom object with likeHostListenerand handle updates to DOM viaRenderer2(assuming that's maybe what you're subscribing for?) but I guess it depends on the whole situation need which isn't quite clear. Sorry can't be more helpful.