代码之家  ›  专栏  ›  技术社区  ›  Abdul Mohaimin

如何在Angular6中使用Async在JSON对象中获取数据收集?

  •  -2
  • Abdul Mohaimin  · 技术社区  · 7 年前

    来自服务器的JSON数据响应是

    { “IsFalm”:真的, “伯爵”:3, “代码”:200, “数据”: { “姓名”:“XXX”, “department”:“CSE”, } { “名字”:“YYY”, “department”:“IT”, } }

    <div *ngFor="let x of hotels$.data | async">
    <hotel-list [listData]="x"></hotel-list>
    

    我在上面尝试过,但没有从循环中得到结果

    1 回复  |  直到 7 年前
        1
  •  2
  •   Sergey Mell    7 年前

    虽然您提供的信息不够,但我想您应该这样做:

    <div *ngFor="let x of (hotels$ | async)?.data">
    

    因为 hotels$ 似乎是可以观察到的但是 hotels$.data 不是。

    推荐文章