【问题标题】:How to get the data from a dummy API and display it using AG grid in angular如何从虚拟 API 获取数据并使用 AG 网格以角度显示它
【发布时间】:2022-01-14 06:39:48
【问题描述】:

我正在尝试显示来自 API 的数据并使用 AG 网格以角度显示它。我正在使用 API using to get the data. 。但我在我的应用程序中收到错误“t.map 不是 o.setRowData 的函数”。在堆栈闪电战中,数据不显示。请通过查看我的示例帮助我显示数据。stack blitz example. please find here

【问题讨论】:

标签: angular pagination ag-grid


【解决方案1】:

您需要在代码中进行以下更改:

HTML:您将收到 Observable 作为响应,因此您必须使用 async 运算符。

[rowData]="rowData | async"

TS:您的 API 返回两个键“元”和“数据”,因此您必须正确映射它

this.rowData = this.http.get<any[]>('https://gorest.co.in/public/v1/users')
.pipe(
  map(res => res.data)
);

链接到stackblitz

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-05
    • 2020-06-28
    • 2023-01-22
    • 1970-01-01
    • 1970-01-01
    • 2021-02-10
    • 1970-01-01
    相关资源
    最近更新 更多