david.adam
david.adam

Reputation: 57

Dynamically Display HTML Table columns from an Array

I have an angular page that returns the following data through an Array

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

What I am trying to do is, display, these Array values in an HTML column

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

Upvotes: 2

Views: 78

Answers (1)

NTP
NTP

Reputation: 4448

You can use ng-repeat to iterate through your array and display columns

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

Upvotes: 2

Related Questions