【问题标题】:print a list of json objects in html after retrieval from firebase ionic从firebase ionic检索后在html中打印json对象列表
【发布时间】:2018-07-06 14:31:39
【问题描述】:

下面的代码是一个附加到离子按钮的简单函数:

viewExpenses(){
  this.afd.list('/expenses').valueChanges().subscribe(res=>{
    this.expenseList = res;
    console.log(JSON.stringify(res));
  });
}  

日志返回 1 个 json 对象的示例列表。

[{"Amount":"100","Description":"asdjasidj","Expense_Date":"2018-06-12","Expense_Name":"opt","Farm_Name":"doodle"}]

我不明白的是我现在如何在html中打印它?

【问题讨论】:

    标签: angular firebase ionic-framework firebase-realtime-database ionic3


    【解决方案1】:

    只需使用插值语法将变量绑定到 html 中,就像这样 -

     {{expenseList | json}}
    

    如果你想显示任何特定的键,你可以像这样使用它 -

    Amount - {{expenseList?.Amount}}
    

    【讨论】:

      猜你喜欢
      • 2017-01-29
      • 1970-01-01
      • 2011-11-09
      • 2022-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-30
      相关资源
      最近更新 更多