我最近開始學習angular js
。我有以下對象ResultRow
:ng-repeat或兩個陣列上類似的東西
ResultRow = function (cars, prices) { //cars and prices are arrays
this.prices = prices;
this.cars = cars;
};
例如,
ResultsRow=new ResultsRow(["Ford","Honda","Nissan"],[20,22,18]);
我想在表格中顯示的ResultsRow
爲:
Car Price
Ford 20
Honda 22
Nissan 18
所以基本上打印車[0],價格[ 0]在一個表格行中,汽車[1],價格[1]在下一個表格行等等。
我嘗試使用ng-repeat
如下:
<tr>
<td ng-repeat="car in ctrl.ResultsRow.cars">
{{car}}
</td>
<td ng-repeat="car in ctrl.ResultsRow.prices">
{{price}}
</td>
</tr>
我有一個很難搞清楚如何顯示我想要的確切格式。任何幫助將不勝感激。
P.S.對於我來說,改變ResultRow的格式非常複雜,因爲我在很多數據操作之後生成了它。
它是* $ scope.rows *不是* var行*。 – NNR
@NNR woops,謝謝。 –