1

Angular datatable make columns dynamic

I have tried to setup datatable with options. the issue is I called api and bind data in table but I cant able to bind column in attribute "columns"

ts file

this.dtOptions = {
      columns: this.tableColumns1,
      // data: this.jsonData.data,
      ajax: (dataTablesParameters: any, callback) => {
        console.log(dataTablesParameters);
        this.http
          .get('https://64422d0d76540ce22585e471.mockapi.io/emp/emplist')
          .subscribe((response) => {
            callback({
              data: response, // <-- see here
            });
          });
      },
    }; 

HTML

<table *ngIf="dtRendered" datatable [dtOptions]="dtOptions" class="row-border hover">

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.