对象的$ scope.array的$ scope.array中的ng-repeat

时间:2015-01-08 18:45:14

标签: angularjs

我想在表格中显示这些数组。一行,然后两列,一行,然后两列等

数组如下所示:

enter image description here

如何运行thess数组以在表中显示attributs?

分块是这样的:

        function chunk(arr, len) {
        $scope.array = arr;
        var chunks = [],
            i = 0,
            n = $scope.array.length;

        while (i < n) {
            chunks.push($scope.array.slice(i, i += len));
        }

        return chunks;
    }

$ scope创建如下:

$scope.criteriasearchprofiles = chunk(dataResponse.data, 2);

4 个答案:

答案 0 :(得分:1)

使用嵌套重复:

<tr ng-repeat="row in rows">
    <td ng-repeat="col in row">{{col}}</td>
</tr>

其中rows是一个数组数组:[Array[2], ...],每个嵌套数组包含列对象

答案 1 :(得分:0)

你去..

enter image description here

我在更多的表中使用了这个对象,它运行正常。我只是不想修改那段代码..

答案 2 :(得分:0)

将此添加到您的HTML:

 <table>
     <tr ng-repeat="criteria in criteriasearchprofiles">
        <td>
            {{criteria.folderName}}  // or any other object attribute
       </td>
       <td>
            {{criteria.selector}} // or any other object attribute
        </td>
    </tr>
</table>

答案 3 :(得分:0)

解决方案:

<tr ng-repeat="outercriteriasearchprofiles in criteriasearchprofiles" >
<td ng-repeat="criteriasearchprofiles in outercriteriasearchprofiles | orderBy:'created':true">
{{criteriasearchprofiles.selector}}
</td>

相关问题