dsh12544 2019-01-11 10:30
浏览 349

在Angular 7数据表中显示数据的问题

I am trying to show the data from my api to my datatable on angular.Api is working fine but i am not able to show that data on my datatable when i click on search button nothing appears in my data tables but data shows on console

Here is ma .ts file code

fetchRollHeader(){
   var apiurl = 'http://localhost/abc/Controller/abc.php';

    var data = new FormData();
    data.append('data', 'fetchRollHeader');
    data.append('roll_id', this.roll_id_start);

      return this.http.post<any>(apiurl, data)

          .pipe(map(response => response))
          .subscribe(
                data=> {
              if(data['response_type'] != undefined && data['response_type'] == 'Error'){

                    if(data['response'] == 29){
                    }else if(data['response'] == 8 || data['response'] == 9 || data['response'] == 10){
                      this.router.navigate(['login']);
                    }else{
                      alert(data['response_value']);


                    }
                }else{
                  this.customers = data;




                }
                 console.log(data);

                },
                error => {
                    console.log("Error", error);
                }
            ); 
  }

Here is my .html file

table datatable class="row-border hover"  style="border:1px solid #f3f3f3">
  <thead>
    <tr >
      <th>ID</th>
      <th>First name</th>
      <th>Last name</th>
    </tr>
  </thead>
  <tbody >
    <tr  *ngFor="let item of customers"   >
      <td >{{item.id}}</td>
      <td >{{item.machine_id}}</td>
      <td >{{item.machine_id}}</td>

      <td>Bar</td>
    </tr>

  </tbody>
</table>

Console Data

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大