Answer the question
In order to leave comments, you need to log in
Why doesn't subscription work after component activation?
I have a service that provides a Subject subscription.
Somewhere in the application a message is sent and listened to in another component.
The problem is that the component is activated by the condition *ngIf
<app-data *ngIf="data"></app-data>
Where data comes from the listener Subject .
In turn, in the component itself, I once again want to listen to Subject .
Tried in `ngOnChanges(): void {}, ngOnInit(): void {}`
Such a suspicion that when creating a component according to the ngIf condition - it scores on subscriptions inside
Answer the question
In order to leave comments, you need to log in
How did you determine that the subscription is not working? It is possible that the component was created after the subject had a value and therefore did not have time to receive anything.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question