logo
Tags down

shadow

how to iterate 2 set data in ng-repeat


By : Eraldy Wardhanu
Date : October 14 2020, 02:24 PM
I hope this helps you . Is it possible to iterate 2 set data in ng repeat, or i have to merge 2 set data into 1? , I think this is what you want...
code :
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope) {
    $scope.students = ['student1' ,'student2' ,'student3' ,'student4' ,'student5' ,'student6'];
    $scope.teachers = ['teacher1' ,'teacher2' ,'teacher3' ,'teacher4' ,'teacher5'];
    
});
table, th , td  {
  border: 1px solid grey;
  border-collapse: collapse;
  padding: 5px;
}
table tr:nth-child(odd) {
  background-color: #f1f1f1;
}
table tr:nth-child(even) {
  background-color: #ffffff;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>

<div ng-app="myApp" ng-controller="customersCtrl"> 

<table>
  <tr ng-repeat="x in students" ng-init="outerIndex=$index">
   		<td>{{ $index + 1 }}</td>
    	<td>{{ x }}</td>
    	<ng-container >
      	 <td ng-repeat="y in teachers" ng-init="innerIndex=$index" ng-show="$index==$parent.$index">
        	<ng-container >
        		<span>{{y}}</span> 
        	</ng-container>
          </td>
    	</ng-container>
  </tr>
</table>
</div>


Share : facebook icon twitter icon

How do I iterate over a sublist with ui:repeat?


By : padmini
Date : March 29 2020, 07:55 AM
will be helpful for those in need If you're using EL 2.2, you can invoke normal java methods.
Assuming that sel is a List here, you can use
code :
<ui:repeat var="crit" value="#{sel.subList(0,12)}">

Iterate on ng-repeat


By : user3371382
Date : March 29 2020, 07:55 AM
Hope that helps If you are trying to figure out how variables and angular works in general, THIS is a great tutorial.
If you're trying to figure out why you can't change the names in your examples, the answer is that you are using a custom directive called ng-table created by this guy to make life a little easier when dealing with tables in angular. Like if you wanted to "group" for example. So $data and $groups, are part of that.
code :
<table class="table">
        <tr ng-repeat="user in myValues">
            <td data-title="'Name'" sortable="'name'">
                {{user.name}}
            </td>
            <td data-title="'Age'" sortable="'age'">
                {{user.age}}
            </td>
        </tr>
 </table>
<table class="table">
       <tr ng-repeat="righteousDude in myValues">
            <td data-title="'Name'" sortable="'name'">
                 {{righteousDude.name}}
            </td>
$scope.righteousDudes = [{name: "Moroni", age: 50},
                {name: "Tiancum", age: 43},.....ect

AngularJS NG-repeat: How to repeat a data inside an ng-repeat that has to filter unique values


By : Martin
Date : March 29 2020, 07:55 AM
may help you . First of all you should target the tabs as id's, and you could set each tab to have the same id as data.category, not $index; toggle should be data-toggle, otherwise it will never work with bootstrap tabs :
code :
<ul class="nav nav-tabs col-lg-4 col-md-4" role="tablist">
  <li ng-repeat="data in tableData | unique: 'category'">
     <a href="#{{data.category}}" role="tab" data-toggle="tab">
       Category {{ data.category }}         
     </a>  
  </li>
</ul>
<div class="tab-content col-lg-8 col-md-8">
  <div role="tabpanel" ng-repeat="data in tableData | unique: 'category'" class="tab-pane" id="{{data.category}}">
    <div ng-repeat="content in tableData">
      <div ng-if="content.category === data.category">
        {{ content | json }}
        <hr>
      </div>     
    </div>
  </div>  
</div>

Iterate through an array in an ng-repeat


By : Jossy Yenga
Date : March 29 2020, 07:55 AM
will be helpful for those in need Assuming your array has the same number of elements as your object that you are iterating through you can use ng-repeat's $index variable which holds the current iteration value.
Also you may want to use track by in your ng-repeat statement if your object might have duplicate entries.
code :
<tbody ng-repeat="ts in allInfo track by $index">
  <tr>
    <td>
       {{ts.id}}
    </td>
    <td>
      {{ts.participant}}
    </td>
    <td>
      {{temp[$index]}} 
    </td>
    <td class="text-capitalize">
      {{ts.action}}
    </td>
  </tr>
</tbody>

Iterate through two different arrays in the same ng-repeat


By : chicgeek
Date : March 29 2020, 07:55 AM
hope this fix your issue I have to iterate through two different arrays containing member details in one array and a approval pending members in another array. I have to display the details in a table. This is the code. , You can concate two arrays in the controller and use it.
JS::
code :
var members = ["a", "b", "c"]; 
var pendingRequests = [1, 2, 3];

var newMembers = members.concat(pendingRequests); 
<div class="member-table-body" ng-repeat="member in newMembers ">
   //code
</div>
shadow
Privacy Policy - Terms - Contact Us © voile276.org