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

黄舟
Release: 2017-06-04 10:44:23
Original
1619 people have browsed it

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 ] ];
Copy after login

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>
Copy after login

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>
Copy after login

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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template