【问题标题】:JSON key contains spacesJSON 键包含空格
【发布时间】:2017-10-17 07:19:07
【问题描述】:

我有以下 json,需要在表中显示其名称为“PAY ALL”、“PAY PART”、“DECLINE”,但键包含其中的空格以及其对应的 pay all 值,pay part 需要显示在相应的表格行数据中。我怎样才能实现它。 我的 json 对象如下-

$scope.tableData={

        "KEY-1": "VALUE-1",

        "KEY-2": "VALUE-2",

        "data": {

            "PAY ALL": {

                    "NumberOfBills": "1800000",

                    "CummalativeBillAmount": "45000000",

                    "ResponseProgress": "60"

                },
                "PAY PART": {

                    "NumberOfBills": "6000000",

                    "CummalativeBillAmount": "15000000",

                    "ResponseProgress": "20"

                },
                "DECLINE": {

                    "NumberOfBills": "3000000",

                    "CummalativeBillAmount": "7500000",

                    "ResponseProgress": "10"

                },
                "REQUEST EXTENSION": {

                    "NumberOfBills": "240000",

                    "CummalativeBillAmount": "6000000",

                    "ResponseProgress": "8"

                }

    }

}

我还需要从上面的 json 响应中实现下表 -

我在我的 html 绑定中尝试了以下内容,但它没有显示任何内容。

<tr ng-repeat="dataValue in tableData">
            <td><img src="./assets/images/Group 384@2x.png" class="img-bo"/></td>
            <td>{{dataValue.data["PAY ALL"]}}</td>
            <td><div class="bg">{{dataValue.data.NumberOfBills}}</div></td>
            <td><div class="bg">{{dataValue.data.CummalativeBillAmount}}</div></td>
            <td><div class="bg">{{dataValue.data.ResponseProgress}}</div></td>
          </tr>

请帮忙。

【问题讨论】:

标签: angularjs json


【解决方案1】:

你的代码应该是这样的

 <table>
  <tr>
    <th>category </th>
     <th>no of bills</th>
     <th>commulative amount</th>
     <th>response</th>
  </tr>
  <tr ng-repeat="(key,value) in tableData.data">
        <td>{{key}}</td>
            <td><div class="bg">{{value.NumberOfBills}}</div></td>
            <td><div class="bg">{{value.CummalativeBillAmount}}</div></td>
            <td><div class="bg">{{value.ResponseProgress}}</div></td>
          </tr>
  </table>

Here is working fiddle

【讨论】:

    猜你喜欢
    • 2017-02-01
    • 2018-05-30
    • 1970-01-01
    • 1970-01-01
    • 2015-09-30
    • 2015-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多