you cannot do it like that. you must first get child2 in the parent using @ViewChild (Child2) (it is important to select ViewChild by component not by line). then you need to catch the event in the parent and execute any method you want on child2. more or less like this:
import { AudioAlbumsComponent } from '...'; import { AudioPlayerComponent } from '...'; @Component({ template: ` <div> <audio-player></audio-player> <audio-albums (trackClick)="onTrackClicked($event)"></audio-albums> </div>`, directives: [AudioPlayerComponent, AudioAlbumsComponent], }) export class Parent { @ViewChild(AudioPlayerComponent) private audioPlayer: AudioPlayerComponent; onTrackClicked($event) { this.audioPlayer.trackChanged($event); } }
source share