动态显示数组中的HTML表列

时间:2019-05-05 12:12:39

标签: angularjs

我有一个角度页面,该页面通过数组返回以下数据

["BO01", "BO03", "BO04", "C.A.1.", "C.F.1.", "C.F.4.", "C.L.1.", "C.M.4.", "C.R.1.", "C.R.3.",…]

我想做的是在HTML列中显示这些Array值

<tr>
    <th class="tg-0lax">BO01</th>
    <th class="tg-0lax">BO03</th>
    <th class="tg-0lax">BO04</th>
  </tr>

1 个答案:

答案 0 :(得分:2)

您可以使用ng-repeat遍历数组并显示列

js

$scope.columns = ["BO01", "BO03", "BO04", "C.A.1.", "C.F.1.", "C.F.4.", "C.L.1.", "C.M.4.", "C.R.1.", "C.R.3."];

html

<tr>
    <th class="tg-0lax" ng-repeat="col in columns">{{col}}</th>
</tr>

Demo