为了账号安全,请及时绑定邮箱和手机立即绑定

如何在 angular 6 中使用 ngFor 循环 JSON 对象

如何在 angular 6 中使用 ngFor 循环 JSON 对象

SMILET 2021-06-16 17:53:40
循环从 json 对象获取的对象列表这是我得到的 json 对象 {  "0": {    "0": null,    "1": "Consolidated Statements of Changes in Stockholders\u2019 Deficit",    "2": null,    "3": "",    "4": "",    "5": "",    "6": "Balance at September 30, 2013",    "7": "",    "8": "Common stock issued for exercise of options",    "9": "Common stock issued for services",    "10": "Common stock issued to employees",    "11": "Common stock returned by employees",    "12": "Net loss for the nine months",    "13": "Shares issued as finance fee",    "14": "Amortization of deferred compensation",    "15": "Common stock issued for acquisition",    "16": "Payment on convertible note",    "17": "Exercise of common stock warrants",    "18": "Unrealized loss on securities, net",    "19": "Preferred stock",    "20": "Balance at June 30, 2014",    "21": "",    "22": "Net loss for the year",    "23": "Amortization of deferred compensation",    "24": "Shares issued for conversion of notes payable",    "25": "Write-off of derivative liability upon conversion",    "26": "Unrealized loss on securities, net",    "27": "Retirement of shares",    "28": "Conversion of Series AA convertible preferred stock",    "29": "Balance at June 30, 2015"  },
查看完整描述

2 回答

?
慕森卡

TA贡献1806条经验 获得超8个赞

您在对象中有对象,因此需要如下运行 for 循环两次。


 <div *ngFor="let items of testObject | keyvalue">

    Key: <b>{{items.key}}</b> 

       <div *ngFor="let item of items | key">

             value:<b>{{item.value}}</b>

       </div>

   <hr>

 </div>


查看完整回答
反对 回复 2021-06-18
  • 2 回答
  • 0 关注
  • 208 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信