Currently facing an issue with a component that utilizes the
changeDetection: ChangeDetectionStrategy.OnPush
The component's logic is as follows:
ngOnInit(){
this.serivce.something
.subscribe( evt => {
// Logic to update values of the array (which is functioning correctly)
});
}
The HTML structure looks something like this:
...
...
<div *ngFor="let item of myArray">
<span *ngIf="item.showEye">TRUE</span>
<span *ngIf="!item.showEye">FALSE</span>
</div>
...
...
The problem arises when using this strategy, as it fails to render the component even after making changes. Before editing, the array appears as follows:
https://i.sstatic.net/x9WZp.png
Note: showEye is set to true.
After the edit, the array now looks like this:
https://i.sstatic.net/uXxhr.png
Although showEye
has been changed to false, nothing reflects in the HTML rendering.
At this point, the question arises - given the inability to remove this strategy, how can one prompt the component to re-render itself?