Angularjs ng-repeat获得价值

时间:2017-04-12 18:25:53

标签: angularjs angularjs-ng-repeat

我在下面得到回复

myresponse

test: {
    "credit": {
        "1500000": [{
            "date": "2016-07-21",
            "balance": -1528750,
            "category": "Transfer out",
            "narration": "test1",
            "amount": -1500000
        },
        {
            "date": "2016-07-21",
            "balance": -1528750,
            "category": "Transfer out",
            "narration": "test1",
            "amount": -1500000
        }]
    },

HTML

<table class="table table-striped table-responsive table-bordered">                        
    <tr>
        <th class="text-center">Months</th>
        <th class="text-center">Data</th>
        <th class="text-center">Balance</th>
        <th class="text-center">Category</th>
        <th class="text-center">Narration</th>
        <th class="text-center">Amount</th>
    </tr>
    <tbody ng-repeat="my in myctrl.credit">
        <tr ng-repeat="(key, val) in my">
            <td></td>
            <td class="text-center">{{val.date}}</td>
            <td class="text-center">{{val.balance}}</td>
            <td class="text-center">{{val.category}}</td>
            <td class="text-center">{{val.narration}}</td>
            <td class="text-center">{{val.amount}}</td>
        </tr>
    </tbody>
</table>

我可以获得所有价值,但我无法进入 1500000 我怎样才能获得此

我也希望合并该月份行

我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:3)

您的ng-repeats嵌套顺序错误。应该是:

<tbody ng-repeat="(key, val) in myctrl.credit">
 <tr ng-repeat="data in val">
  //data has date, balance, etc
  //key = 150000