问题描述:在Angular中,API响应的数据未能正确地显示在表格中。
解决方法:
import { HttpClient } from '@angular/common/http';
export class DataService {
  constructor(private http: HttpClient) {}
  getData() {
    return this.http.get('api/url');
  }
}
export class MyComponent implements OnInit {
  public data: any[];
  constructor(private dataService: DataService) {}
  ngOnInit() {
    this.dataService.getData().subscribe((response: any[]) => {
      this.data = response;
    });
  }
}
  
    
      Column 1 
      Column 2 
     
  
  
    
      {{ item.column1 }} 
      {{ item.column2 }} 
     
  
请注意,上述代码只是示例,具体实现可能会根据实际情况有所不同。