I have a collapse-able panel which takes sometime to open as it has to render around 10K to 80K records, and for which I have used *ngFor. And since it takes a lot of time to render it appears as the application is crashed/stuck. So I wanted to show a loader, which we have in our product.
I am trying to emit the values from the child component to parent component where I want to show the loader(i.e block the parent component while the child component completes the rendering).
Below is my HTML code
<li class="panel" *ngFor="let filter of filterData; let ind = index" id="qa-{{filter.NameFilterlet filter of filterData; let ind = index" id="qa-{{filter.NameFilter}}" >
<div class="filter-list__cont-menu-item-name" [ngClass]="{'active': filter.NameFilter === selectedTitleFilter || resultFilter}"
data-toggle="collapse" role="tab" [attr.data-target]="'#filter' + ind" aria-expanded="false"
(click)="onTitleFilter(filter.NameFilter)">
<fa-icon class="caretr" [icon]="['fas', 'caret-right']"></fa-icon>
<span class="main-name">{{getNameFilter(filter)}}</span>
</div>
<div class="collapse filter-list__cont-sub-menu" [ngClass]="{'in': stateOpen}" role="tabpanel" id="filter{{ind}}"
aria-expanded="false">
<ul>
<li *ngFor="let subFilter of filter.SubFilters" id="qa-{{subFilter.Name}}" (click)="onFilter(subFilter.Name, subFilter.Id, filter.NameFilter)"><div class="subFilter-name" data-toggle="tooltip" data-placement="right" title="{{subFilter.Name}}">{{subFilter.Name}}</div></li>
</ul>
</div>
</li>
Below is my component.ts file code for on click of the tile which is expanded so show the records. I had tried setting the value to TRUE at the start and FALSE at the end, but since it is a method the TRUE value is turned to FALSE within a second.
onTitleFilter(titleFilter: string) {
this.startLoading.emit(true)
if (!this.resultFilter) {
this.selectedTitleFilter = this.selectedTitleFilter === titleFilter ? '' : titleFilter;
}
this.startLoading.emit(false)
}
What can I do to show the loader while the *ngFor completes its rendering? Any solution?