如何将数据放入angular6的数据表中?

时间:2019-03-19 13:00:24

标签: datatable angular6

这是我的打字稿代码,已成功在控制台数据中找到,但我无法将其放入数据表中,也没有显示错误,请帮助我找到解决办法。

ngOnInit() {

this.dtOptions = {
  pagingType: 'full_numbers',
  pageLength: 10,
  processing: true,
  ajax: (dataTablesParameters:any)=>{
    this.http.get(environment.api_url + `/admin/get_all_product`).subscribe((data:any[]) =>{
      console.log(data);
      //this.products = data as any[];
      this.dtTrigger.next();
    }); 
  },
  columns: [{
    title: 'ID',
    data: '_id'
  }, {
    title: 'Product Name',
    data: 'product_name'
  }, {
    title: 'Product Description',
    data: 'product_description'
  },
  {
    title: 'Product Price',
    data: 'product_price'
  },{
    title: 'Product Quantity',
    data: 'product_quantity'
  },
  {
    title: 'Product Category',
    data: 'product_category'
  }]
};

this.http.get(environment.api_url + `/admin/get_all_product`,{   
}).subscribe((data:any[]) =>{
  console.log(data);
  //this.products = data as any[];
  this.dtTrigger.next();
});

}

这是html代码,

<table datatable [dtOptions]="dtOptions" [dtTrigger]="dtTrigger" class="row-border hover"></table>

0 个答案:

没有答案