Estoy trabajando en una función que permite a un usuario crear su propia tabla. Me gustaría refactorizar este código.
Por lo tanto, crea una cantidad de filas en función de las filas máximas que tengo y también aumenta una posición de fila cada vez sin que yo codifique cada fila.
Un ejemplo del código que tengo es el siguiente:
<div ng-show="components.length != 0"> <h3> Output Preview: <button Class="btn btn-primary" ng-show="components.length > 1" ng-click="hidePositionChange=(hidePositionChange ? false : true)">Change row/order position</button> </h3> <div> <table> <tr> <td ng-repeat="component in components track by $index" ng-show="component.RowPosition == 0">{{component.Text}}{{component.Field}}</td> </tr> <tr> <td ng-repeat="component in components track by $index" ng-show="component.RowPosition == 1">{{component.Text}}{{component.Field}}</td> </tr> <tr> <td ng-repeat="component in components track by $index" ng-show="component.RowPosition == 2">{{component.Text}}{{component.Field}}</td> </tr> ...<div ng-show="components.length != 0"> <h3> Output Preview: <button Class="btn btn-primary" ng-show="components.length > 1" ng-click="hidePositionChange=(hidePositionChange ? false : true)">Change row/order position</button></h3> <div> <table> <tr ng-repeat="componentRow in components track by $index | limitTo: maxItems | orderBy: '+RowPosition'"> <td ng-repeat="component in components | limitTo: 3" ng-if="component.RowPosition == $index">{{component.Text}}{{component.Field}}</td> </tr> </table> </div> </div>