'Component doesn't see subscription changes
component.ts
export class MyComponent implements OnInit {
constructor(
private router: Router,
private store: Store<fromApp.State>
) {}
loading: boolean;
ngOnInit(): void {
this.store.select('myState').subscribe(({ loading }) => {
this.loading = loading;
console.log(this.loading);
});
}
}
component.html
<div *ngIf="loading">
loading
</div>
<div *ngIf="!loading">not loading</div>
In the browser console i can see the switch between the two states loading=false and loading=true. However, in the browser i always see "loading". What am i missing here?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
