After searching through numerous SO posts in search of a solution, I finally stumbled upon one that involved a hacky implementation. The issue at hand involves an observable extracted from the ngrx store which I then subscribe to:
this.navigationSelected$ = this.store.pipe(select(currentlySelectedNavigation));
this.navigationSelected$.subscribe(res => {
...
});
This subscription is used within the template with an ngIf statement that depends on the value of this observable:
<profile-navigation *ngIf="(navigationSelected$ | async) == navigationLayout[0].location"></profile-navigation>
However, each time the navigationSelected$ value changes, it triggers the following error:
ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngIf: [object Object]'. Current value: 'ngIf: false'.
Even though calling cdRef.detectChanges() at the end of the subscription resolves the issue, the error persists and the solution feels like a workaround. Is there a better approach to achieve the desired outcome?