Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

273
Views
Why does my UI freeze until the api call is terminated?

I have an API call that downloads all Italian municipalities, which is nearly 8000. The problem is that the page loads the HTML, but I can't click anything until the API call is over.

ngAfterViewInit(){
    this.loadComuni();
}
loadComuni(){
   //Italian municipalities
   this.RegisterService.getMunicipalities().subscribe(
      obj=>{
        this.city=obj;
      },
      error=>{
        console.log("error", error);
   });
}


<div class="col-12 col-lg-4"">
 <select id="cbComNasc" class="form-control" formControlName="cbComNasc">
      <option *ngFor="let c of city" [ngValue]="c.citta">{{c.citta}}</option>
 </select>
</div>



//getMunicipalities
  public getMunicipalities():Observable<Comuni[]>{
    const httpOptions = {
      headers: new HttpHeaders({
        "Content-Type": "application/json; charset=UTF-8",
        'Accept':  'application/json'
      })
    }; 
    return this.HttpClient.get<Comuni[]>(environment.apiURL+"api/v1/gestionale/GetComuni",httpOptions)
  }

I also tried with the async pipe or with the promise but the problem is the same.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I too had the same issue. If you're having a large amount of data ngFor will take some time to render them, so have a separate array and render 10 to 20 records initially and if the user scroll to the bottom render 10 t0 more or have a pagination feature.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!