Home >Web Front-end >JS Tutorial >Example code sharing on how angularJS uses ng-repeat to traverse a two-dimensional array

Example code sharing on how angularJS uses ng-repeat to traverse a two-dimensional array

黄舟
黄舟Original
2017-06-04 10:44:231616browse

This article mainly introduces the example code of angularJSusing ng-repeat to traverse two-dimensional array. It has certain reference value. Interested friends can refer to it

Recently I am working on a report project. In one case, what is returned to me in the background is a two-dimensional array, and the data is put into the table in the front desk, because we are using AngularJS. FrontendFramework, so use ng-repeat to implement:

First in js:

The code is as follows:

$scope.Week = [[ '云南省 ', 'a', 's', 'd', 'e', 'w','t' ],[ '陕西省 ', 'l', 'p', 'o', 'i', 'u','y' ],[ '青海省 ', 1, 2, 4, 4, 5, 6 ] ];

In HTML :

Style one:

<ul ng-repeat="a in Week">
<ul ng-repeat="b in a track by $index">
<li><b style="color: green">{{b}}</b></li>
</ul>
</ul>

Style two:

<table style="border:solid 1px">
<tr ng-repeat="a in Week" style="border:solid 1px">
<td ng-repeat="b in a track by $index" style="border:solid 1px">
<b style="color: green">{{b}}</td>
</tr>
</table>

The above is the detailed content of Example code sharing on how angularJS uses ng-repeat to traverse a two-dimensional array. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn