我试图使用Angular 1.4.8填充表格。
为什么要赢得这项工作......
<td ng-if="fila" ng-repeat="celda in fila">{{ celda }}</td>
...但 ?
<td ng-if="fila">{{ fila[0] }}</td>
<td ng-if="fila">{{ fila[1] }}</td>
<td ng-if="fila">{{ fila[2] }}</td>
<td ng-if="fila">{{ fila[3] }}</td>
我的代码如下。
var app = angular.module('myApp', []);
app.controller('ctrlTest', function($scope) {
$scope.tabla = {
titulos: ['Caracteristicas', 'Opcion1', 'Opcion2', 'Opcion3', 'Opcion4'],
datos: {
'Caracteristica1': [25, 500, 500, 2500],
'Separador': '',
'Caracteristica2': ['-', 'X', 'X', 'X'],
'Caracteristica3': ['-', '-', 'X', 'X']
}
};
});
&#13;
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.min.js"></script>
<div ng-app="myApp">
<table ng-controller="ctrlTest">
<tr>
<th ng-repeat="titulo in tabla.titulos">{{ titulo }}</th>
</tr>
<tr ng-repeat="(clave,fila) in tabla.datos">
<th ng-if="fila">{{ clave }}</th>
<th ng-if="!fila" colspan="{{ (tabla.titulos).length }}">{{ clave }}</th>
<td ng-if="fila" ng-repeat="celda in fila">{{ celda }}</td>
</tr>
</table>
</div>
&#13;
答案 0 :(得分:2)
您在转发器中有重复项。将$ index添加到你的ng-repeat =&#34; celda in fila&#34;:
//Input
5
abba
ebacaba
bcd
er
abacaba
//Output
ebacabaabacabaabbabcder