带有一个嵌套col的ng-repeat表

时间:2016-01-15 15:36:11

标签: javascript angularjs loops html-table angularjs-ng-repeat

我有工作代码:

senderAddress = {
    key1 = "val1",
    key2 = "val2",
    billings = {"bilKey1": "bilVal1", "bilKey2", "bilVal2" ...},
    keyN = "valN"
};
<table class="table table-hover" >
    <tbody>
        <tr ng-repeat="(key, value) in senderAddress">
            <td>
                <strong translate="senderAddress.details.{{key}}"></strong>
            </td>

            <td ng-if="key === 'billing'">
                <table class="table table-hover">
                    <tbody>
                        <tr ng-repeat="(billingKey, billingValue) in value">
                            <td>
                                <strong translate="senderAddress.details.billings.{{billingKey}}"></strong>
                            </td>
                            <td ng-switch="key">
                                <span ng-switch-when="expiration_date">{{billingValue | date:'MMM d, y H:mm:ss'}}</span>
                                <span ng-switch-default="">{{billingValue}}</span>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <span></span>
            </td>

            <td ng-if="key !== 'billing'" ng-switch="key">
                <span ng-switch-when="created_date" >{{value| date:'MMM d, y H:mm:ss'}}</span>
                <span ng-switch-when="last_updated_date" >{{value| date:'MMM d, y H:mm:ss'}}</span>
                <span ng-switch-when="birth_date" >{{value| date:'MMM d, y H:mm:ss'}}</span>
                <div ng-switch-when="attachments" >
                    <show-attachments info="value"></show-attachments>
                </div>
                <span ng-switch-default>{{value}}</span>
            </td>
        </tr>
    </tbody>
</table>

除了以外输出表格:

-------------------------------------
|key1    |val1                      |
-------------------------------------
|key2    |val2                      |
-------------------------------------
|        |bilKey1  | bilVal1|       |
|billings|bilKey2  | billVal2       |
|        |bilKey2  | billVal2       |
-------------------------------------
|keyN    |valN                      |
-------------------------------------

我需要以下输出:

-------------------------------------
|key1    |val1                      |
-------------------------------------
|key2    |val2                      |
-------------------------------------
|billings|                          |
-------------------------------------
|        |bilKey1   |bilVal1        |
|        |bilKey2   |bilVal2        |
|        |bilKey3   |bilVal3        |
-------------------------------------
|keyN    |valN                      |
-------------------------------------

0 个答案:

没有答案