problems with child components in Angular

Viewed 53
1 Answers

I run the stackblitz and it seems both components returned the proyectoId correctly - so I assume it might depend on some other things as well and not easily reproduced?

Your issue might be that the proyecto$ observable comes from BehaviourSubject. This means that if not value was pushed to that subject, it will emit null.

Your ngIf <div *ngIf="proyecto$ | async as proyecto"> will return true as soon as the observable emits. So, if no proyecto was pushed to the BehaviourSubject, it will return true and proyecto will be null. This might be the cause of your issue.

Again, it's hard to say because it seems that there is some race condition that causes the issue to not always happen.

Related