I have a template:
<div *ngFor="let order of orders" (click)="showReglamentList =! showReglamentList">
<app-dropdown-reglaments *ngIf="showReglamentList" [depid]="order.depId"></app-dropdown-reglaments>
</div>
When user clicks over row it toggles showReglamentList
, so component app-dropdown-reglaments
is activated.
But now it activates all components in each row (loop) with server request.
I can solve this like this:
let rowComponentVisibility = {};
orders.foreach((item, index) => rowComponentsVisibility[index] = false);
Then use:
*ngIf="rowComponentsVisibility[index]"
Problem is I try to cache it, and dont initialize the component again, just hide/show if it was initilized before.
How to solve it?