Displayed even when data is present, the PrimeNg empty message persists

I have set up a PrimeNg table to display data with an empty message template like this:

<ng-template pTemplate="emptymessage">
   <tr>
     <td>
         No records found
      </td>
    </tr>
 </ng-template>

Additionally, I am using lazy loading for server-side data retrieval. Upon completion of the HTTP call, a loading flag is toggled. Here is the relevant code snippet:

this.myService
    .myHttpCallFunction(params)
    .pipe(
        finalize(() =>{ this.loading = false;}, 100)
    )
    .subscribe(
        (result: JsendResponse) => this.data = result.data,
         errors => this.errors = errors
    );

The loading flag is passed to the table as follows:

 <p-table [value]="data?.data" [columns]="settings.columns" [loading]="loading">

Currently, the interface first displays a loading icon and then the empty message before showing the actual data. This may lead to confusion for users who might mistakenly assume there is no data present due to the premature display of the empty message.

Answer №1

Revise your code as shown:

this.customService
    .customHttpFunction(inputs)
    .subscribe(
        (output: ApiResponse) => {
          this.payload = output.data;
           this.isReady = false;
        },
         faults => this.faults = faults
    );

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to simulate a dependent class in TypeScript & JEST without modifying constructor parameters to optional

Currently, I am attempting to replicate a well-known process in Java development using TypeScript and JEST for practice. In this scenario, there is a Controller class that relies on a Service class. The connection between the two is established through the ...

What is the procedure for implementing a RoleGuard in Angular 6?

Is there a way to retrieve the user role from the token? I've managed to fetch the token using the decoding feature of angular2-jwt, but when I try to apply it for accessing the admin route, it returns a value of false. Upon checking with console.lo ...

Unable to export Interface in Typescript - the specific module does not offer an export named Settings

I am encountering an issue while trying to export/import an interface in Typescript. The error message I receive is causing confusion as I'm unsure of where I went wrong. Uncaught SyntaxError: The requested module '/src/types/settings.ts' ...

Globalizing Your Angular 4 Application

Looking for a way to enable Internationalization (i18n) on button click in Angular 4 with support for at least four languages? I attempted to use the Plunker example provided here, but it seems to be encountering issues: ...

The issue of inconvenience arises when dealing with `as const` arrays, as the readonly T[] is not directly assignable to T[]. The challenge lies in how to effectively remove

I encounter this issue repeatedly (playground link): const arr = [1,2,3] as const const doSomethingWithNumbers = <T extends number[]>(numbers: T) => {} doSomethingWithNumbers(arr) // ^ // Argument of type 'readonly [1, 2 ...

Vercel: Failed to create symbolic link, permission denied

I have my personal repository available at https://github.com/Shrinivassab/Portfolio. I am currently working on developing a portfolio website. However, when I attempt to execute the vercel build command, I encounter the following error: Traced Next.js ser ...

Error in typing on a prismic application utilizing a ContentRelationshipField

I am facing a type error in my Prismic Next.js application that I am struggling to resolve. While the app functions properly, I keep encountering type errors like the following: The property 'data' does not exist on the type 'ContentRelati ...

Angular: Utilizing property interpolation from fetched JSON

As I attempt to create a test questionnaire using a json response, I encounter errors in the console stating 'Cannot read property 'Title' of undefined'. It seems like the string interpolation is trying to occur before receiving the res ...

Tips for initializing and updating a string array using the useState hook in TypeScript:1. Begin by importing the useState hook from the

Currently, I am working on a React project that involves implementing a multi-select function for avatars. The goal is to allow users to select and deselect multiple avatars simultaneously. Here is what I have so far: export interface IStoreRecommendation ...

Mastering ngClass for validation in Angular 2: Step-by-step guide

I am facing an issue with a form I have created where I applied ngclass to display an error when the form value is missing. However, the error is showing up when the form is initially loaded. It seems that by default, my input tag is invalid when the form ...

Issue with Spring Boot project not updating data from database

Recently, I have been delving into a full stack application project using Angular and Spring Boot for the first time. Following a comprehensive tutorial has guided me through this journey. Starting with a project downloaded from , I included various depen ...

"Learn how to utilize array values in TypeScript to easily display them using NgFor in HTML

Looking for a solution: <select (change)="getYear(year)"> <option value="year" *ngFor="let var of array; let i = index" {{year.year}} </option> </select> Is there a way to configure the typescript code so that I can dynamica ...

Understanding the timing of records being returned via an Observable in Angular's ngOnInit

In my Angular 2 application, I am using an observable to keep track of an array of records. As the results of this observable are stored in the variable "records", I am utilizing *ngFor="let record of records" to iterate over and display them in my view. ...

What is the reason behind Typescript's discomfort with utilizing a basic object as an interface containing exclusively optional properties?

Trying to create a mock for uirouter's StateService has been a bit challenging for me. This is what I have attempted: beforeEach(() => { stateService = jasmine.createSpyObj('StateService', ['go']) as StateService; } ... it(& ...

What is the best way to trigger an event within an Angular app using RxJS in version 10?

As I venture into the world of Angular10, I find myself experimenting with a Canvas and honing my skills in drawing on it. Let's refer to the object drawn on the canvas as a "Foobar" - my Angular10 code for drawing Foobars is coming along nicely. Util ...

Using ngrx store select subscribe exclusively for designated actions

Is it possible to filter a store.select subscription by actions, similar to how we do with Effects? Here is an example of the code in question: this.store .select(mySelector) .subscribe(obj => { //FILTER SUBSCRIPTION BY ACTION this.object = ob ...

Count the number of checkboxes in a div

In my current project, I am working on incorporating three div elements with multiple checkboxes in each one. Successfully, I have managed to implement a counter that tracks the number of checkboxes selected within individual divs. However, I now aspire to ...

Tips for addressing a situation where an npm package encounters issues during AOT compilation

As a newcomer to web development, I am currently struggling with an issue that has me stumped. Within my web application, I am utilizing the npm package called @uniprank/ngx-file-uploader (https://www.npmjs.com/package/@uniprank/ngx-file-uploader). While ...

Converting an Observable variable to a specific type in Typescript

I am currently utilizing Angular 12. To avoid duplicating the same service logic, I am experimenting with creating a base class that includes all HTTP methods and then extending a child class to utilize in the components. crud.service.ts @Injectable({ ...

Utilizing StyleFunctionProps within JavaScript for Chakra UI Enhancements

I need help figuring out how to implement StyleFunctionProps in my Chakra UI theme for my NextJS project. The documentation on Chakra's website provides an example in Typescript, but I am working with Javascript. Can someone guide me on adapting this ...