Angular Json文件未在html表中显示数据

Angular Json文件未在html表中显示数据,angular,Angular,在我的应用程序中,数据来自webapi。下面是代码 --- [HttpGet] public JsonResult Get() { string dte = "2021-01-01"; string uname = "baiju"; SqlConnection con = new SqlConnection("Server=LAPTOP-30BV9E85\\SQLSERVER;D

在我的应用程序中,数据来自webapi。下面是代码

---
[HttpGet]
    public JsonResult Get()
    {
        string dte = "2021-01-01";
         string  uname = "baiju";
        SqlConnection con = new SqlConnection("Server=LAPTOP-30BV9E85\\SQLSERVER;Database=Lekshmi;    user id=sa;password=baiju");


        SqlCommand cmd = new SqlCommand("Sp_Bookstatus3", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@dte", dte);
        cmd.Parameters.AddWithValue("@uname", uname);
        //  SqlCommand cmd = new SqlCommand("select * from busmaster", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        con.Open();
        da.Fill(ds);
        con.Close();
        return new JsonResult(ds.Tables[0]);

    }
---
got following output after breakpoint in code
在浏览器中跟踪输出 零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零,零零


它是一种表格格式,如

ID 01 02 03 31

100零零零

101零零零

我的要求是显示在有角度的页面

角度编码

appcomponent.ts

从'@angular/core'导入{Component,OnInit};
从“jquery”导入*为$;
从'src/app/shared.service'导入{SharedService};
@组成部分({
选择器:'应用程序根',
templateUrl:“./app.component.html”,在此处输入代码
样式URL:['./app.component.css']
})
导出类AppComponent实现OnInit{
构造函数(私有服务:SharedService){}
DepList:any=[];
恩戈尼尼特(){
this.service.getList().subscribe(数据=>{
this.DepList=数据;
这个。_object=object;
console.log(this.DepList);

});
在component.ts文件中

export class AppComponent implements OnInit {

  data = [];
  headers: string[];

  constructor(private service: SharedService){}

  ngOnInit() {
    this.service.getList().subscribe(data=>{
      this.data = data;
      this.headers = Object.keys(this.data[0]).sort()
      this.headers.splice(0, 0, this.headers.pop());
    });
  }
}
在component.html文件中

<table>
  <tr>
    <th *ngFor="let header of headers">{{header}}</th>
  </tr>
  <tr *ngFor="let row of data">
    <td *ngFor="let key of headers">{{row[key]}}</td>
  </tr>
</table>

{{header}}
{{行[键]}}

此代码不工作iam使用angular 11这不是angular的问题。它在Bootstrap中唯一的显示表问题如果它是10列,如ID 01…09,则显示良好。如果它超过10。第10列将是向前的第一列。这与angular版本无关。我使用硬编码数据进行测试。您能硬编码吗在数据处,而不是调用服务并尝试它。这是mecheck的工作