【问题标题】:JS/Angular - ngIf with map that is returned from endpointJS/Angular - ngIf 与从端点返回的地图
【发布时间】:2019-03-20 16:10:44
【问题描述】:

我有一个结果返回的端点

HttpEntity<Map<String, Any?>>

我想要做的是检查地图不为空,当不为空时,我想打印例如某个键的值。如果它是空的,我想打印类似“数据不可用”的消息。

这是我的示例方法:

getCallsNumber(databaseId,from,to): Observable <{value: number; difference : number}>{
    return this.http.get(this.dbBaseURL + '/calls?databaseId=' + databaseId + "&from=" + from + "&to=" + to).pipe(map((res: {value: number; difference: number}) => res));
}

有人可以帮助我吗? *ngIf="(calls | json) != '{}' 在 div 中不起作用..

【问题讨论】:

    标签: angular typescript rxjs frontend


    【解决方案1】:

    你应该使用 Angular 的 async 管道。

    *ngIf="(calls | async | json) != '{}'" 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-23
      • 2018-07-10
      • 2018-07-02
      • 1970-01-01
      • 1970-01-01
      • 2020-12-23
      • 1970-01-01
      相关资源
      最近更新 更多