1Parent-Component
2
3eventsSubject: Subject<void> = new Subject<void>();
4
5emitEventToChild() {
6 this.eventsSubject.next();
7}
8
9
10Parent-HTML
11
12<child [events]="eventsSubject.asObservable()"> </child>
13
14
15Child-Component
16
17private eventsSubscription: Subscription;
18
19@Input() events: Observable<void>;
20
21ngOnInit(){
22 this.eventsSubscription = this.events.subscribe(() => doSomething());
23}
24
25ngOnDestroy() {
26 this.eventsSubscription.unsubscribe();
27}