Skip to content
Advertisement

How to fetch data from API in ng2 smart table?

I have an angular app using Ng2 smart table and need to fetch data from API I create a method to fetch data from API (but I didn’t know it works or not ) and the main problem is how to get data to show in ng2 smart table Following is my HTML code

JavaScript

my service .ts

JavaScript

component .ts :

JavaScript

so I need some help to get data and how to but it in component .ts dataMain array, thanks in advance and excuse me because I’m a beginner.

Advertisement

Answer

[source]=”dataMain” from your html template needs to be set to whatever Array you are fetching from the API.

I’m assuming you want your Client data to show, as the function

getClientData() appears to be returning an array of clients:

JavaScript

your HTML settings should have [source]="this.clients" instead of dataMain, since this.clients is the variable that holds the list you want to show.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement