我正在尝试在角度材料表中显示数据,这里是获取从 API 获取数据的请求
export class ProductsListComponent implements OnInit {
// Table fields
displayedColumns = ['select', 'country', 'actions'];
datasource = ????? //how should I give api's data source
}
ngOnInit() {
let observ = this.http.get('https://kbzp6jhg2h.execute-api.us-east-1.amazonaws.com/Prod/api/v1/hierarchy/countries?status=1');
observ.subscribe((res)=> {
console.log("response from api",res['data']);
});
这是我想显示来自 API 的数据的 html 文件
<mat-table class="lmat-elevation-z8" #table [dataSource]="dataSource">
<ng-container matColumnDef="country">
<mat-header-cell *matHeaderCellDef>Country Name</mat-header-cell>
<mat-cell *matCellDef="let product">{{product.name}}</mat-cell>
</ng-container>
</mat-table>