Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
How to ng-repeat this table row and increase the ng-show row position value instead of hard coding the values

I am working on a feature which allows a user to create their own table. I'd like to refactor this code.

So it creates a number of rows based on the max rows I have and also increases a row position each time without me hard coding each row.

An example of the code I have is below:

<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>
...
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

<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>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!