How can I increase the performance when rendering a template multiple times using ngFor? I have a situation where I need to show the same template based upon the count. I am doing this using *ngFor.
The template loads correctly but I am worried about the performance. Because I need to repeatedly show the same content for a few thousand times, then the performance will be slow after the template is loaded. I have made a plunker demo here http://plnkr.co/edit/qTj4SVRnFD6N15PZ1GWC?p=preview - please increase the count of formgroups in formarray with a difference of 1000 then the system will be slow or breaks down.
This is how I create the formarray:
for(var i=0;i<100;i++){
let dummyFormGroup=this.fb.group({
'name':[''],
'place':['']
})
this.dummyFormArray.push(dummyFormGroup);
}
And I render the controls in formarray using ngFor like this:
<div *ngFor="let formgroup of dummyFormArray.controls" style="display:flex;flex-direction:row">
<p>
<label>Name:</label>
<input type="text" [formControl]="formgroup.controls['name']" />
</p>
<p>
<label>Place:</label>
<input type="text" [formControl]="formgroup.controls['place']" />
</p>
How can I increase the performance once the template is loaded? Because I am OK with waiting for the template to load if it needs to render thousands of records. But once the template is ready I want the system to be fast in this case using *ngFor.