Ich habe ein Array von Paaren, die ich in einer Tabelle anzeigen muss, wo die erste Spalte 2 Zeilen wie im Bild überspannt.ngRepeat über Paare zum Erstellen von Tabelle mit rowspan = "2"
Das Array wie folgt aussieht:
$scope.products = [{
p0: {name: "n1", img: "a", brand: "apple", desc: "1"},
p1: {name: "n2", img: "b", brand: "apple", desc: "2"}
},{
p0: {name: "n3", img: "c", brand: "apple", desc: "3"},
p1: {name: "n4", img: "d", brand: "apple", desc: "4"}
},{
p0: {name: "n5", img: "e", brand: "apple", desc: "5"},
p1: {name: "n6", img: "f", brand: "apple", desc: "6"}
},{
p0: {name: "n7", img: "g", brand: "apple", desc: "7"},
p1: {name: "n8", img: "h", brand: "apple", desc: "8"}
}];
Die "Hardcoded" Version dieses
wäre<table class="table table-bordered">
<tr>
<th></th>
<th>Brand</th>
<th>Product name</th>
</tr>
<tr>
<th rowspan="2">a b</th>
<td>apple</td>
<td>n1</td>
</tr>
<tr>
<td>apple</td>
<td>n2</td>
</tr>
<tr>
<th rowspan="2">c d</th>
<td>apple</td>
<td>n3</td>
</tr>
<tr>
<td>apple</td>
<td>n4</td>
</tr>
</table>
Ich weiß nicht, wie ich das mit einer ng-repeat erreichen kann. Ich habe versucht, etwas albern wie der Code unten, aber offensichtlich hat es nicht funktioniert. Hilfe?
<div ng-repeat="pair in products">
<tr>
<th rowspan="2">{{pair.p0.img}} {{pair.p1.img}}</th>
<td>{{pair.p0.brand}}</td>
<td>{{pair.p0.name}}</td>
</tr>
<tr>
<td>{{pair.p1.brand}}</td>
<td>{{pair.p1.name}}</td>
</tr>
</div>
hinzugefügt haben, das war es, danke! – bvais