I tried to follow this answer but its too confusing Angular 2 event catching between sibling components
I want to call a method in child component 1 when something is clicked on child component 2
Child component 2 emits an event called trackClick.
Parent Component:
<div>
<audio-player></audio-player>
<audio-albums></audio-albums>
</div>
Child Component 1 (audio-player)
// Don't know what to do here, want to call this function
trackChanged(track){
console.log("YES!! " + track);
}
Child Component 2 (audio-albums)
<li class="track" (click)="playTrack(track)"> </li>
@Output() trackClick = new EventEmitter<any>();
playTrack(track):void{
console.log("calling playTrack from child 2:" + track);
this.trackClick.next([track]);
}