0

How can I create a dynamic matrix table in Angular 2?

The matrix should look like this:

    Test1   Test2   Test3
 A  1,5     1,8     1,6
 B  1,8     1,6     1,9
 C  1,6     1,6     1,8

This is just an example data. The size of the json is dynamically. I can have more tests than 3. my Json:

data = [{
 "test": "Test1",
  results: [{
    "env": "A",
    "result": 1,5
  }, {
    "env": "B",
    "result": 1,8
  }, {
    "env": "C",
    "result": 1,6
  }]
}, {
  "test": "Test2",
  results: [{
    "env": "A",
    "result": 1,5
  }, {
    "env": "B",
    "result": 1,7
  }, {
    "env": "C",
    "result": 1,6
  }]
}, {
  "test": "Test3",
  results: [{
    "env": "A",
    "result": 1,8
  }, {
    "env": "B",
    "result": 1,6
  }, {
    "env": "C",
    "result": 1,6
  }]
}];

thanks in advance

trap
  • 2,550
  • 7
  • 21
  • 42

1 Answers1

0

Possible solution might be two embeded *ngFor-s:

<div *ngFor="let row of data">
  <span *ngFor="let column of row.results>
    {{column.result}}
  </span>
</div>

Also, please read about this site's guide about how to ask good questions sou you will get more answers.

ForestG
  • 17,538
  • 14
  • 52
  • 86