使用ng-repeat在Angular中渲染数组数组表

ps0*_*604 4 angularjs

我有一个数组数组(表示行和列),我需要使用数据呈现HTML表.

每行都是一个列值数组,例如: $scope.table.row[0] = [123, 456, 789]

这是我的尝试(这不起作用).有任何想法吗?

<table>
    <tbody>
        <tr ng-repeat="row in table">
            <td ng-repeat="col in row">{{col}}</td>
        </tr>    
    </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

Yur*_*nko 6

您需要迭代table.row或自己创建table一个数组数组.演示.

<table>
    <tbody>
        <tr ng-repeat="row in table.row">
            <td ng-repeat="col in row">{{col}}</td>
        </tr>    
    </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

要么

table = [ [123, 456, 789], [111, 222, 333], [111, 222, 333]]

<table>
    <tbody>
        <tr ng-repeat="row in table">
            <td ng-repeat="col in row">{{col}}</td>
        </tr>    
    </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)