K
K
Konstantin2020-01-30 13:31:56
Angular
Konstantin, 2020-01-30 13:31:56

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

1 answer(s)
A
Anton Shvets, 2020-01-30
@Junart1

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 question

Ask a Question

731 491 924 answers to any question