nested ng-repeat

19 views
Skip to first unread message

priom biswas

unread,
Jan 22, 2017, 10:53:09 AM1/22/17
to Angular
I'm new to this group and I have a question regarding ng-repeat, following is my json data:

$scope.routines = [
   
{ CLASSTIME_ID: 1, COURSE_CODE: "CSTE-1001", SEMESTER_ID: "1st", WEEKDAY: "Sunday" },
   
{ CLASSTIME_ID: 2, COURSE_CODE: "CSTE-1002", SEMESTER_ID: "1st", WEEKDAY: "Sunday" },
   
{ CLASSTIME_ID: 1, COURSE_CODE: "CSTE-1003", SEMESTER_ID: "2nd", WEEKDAY: "Monday" }
   
];

    $scope
.classtimes = [
       
{ CLASSTIME_ID: 1 ,CLASSTIME: "9.00-9.50" },
       
{ CLASSTIME_ID: 2, CLASSTIME: "10.00-10.50" },
       
{ CLASSTIME_ID: 3, CLASSTIME: "11.00-11.50" },
       
{ CLASSTIME_ID: 4, CLASSTIME: "12.00-12.50" },
       
{ CLASSTIME_ID: 5, CLASSTIME: "14.00-14.50" },
       
{ CLASSTIME_ID: 6, CLASSTIME: "15.00-15.50" },
       
{ CLASSTIME_ID: 7, CLASSTIME: "16.00-16.50" }
   
];

    $scope
.weekdays = [
       
{ WEEKDAY: "Sunday" },
       
{ WEEKDAY: "Monday" },
       
{ WEEKDAY: "Tuesday" },
       
{ WEEKDAY: "Wednesday" },
       
{ WEEKDAY: "Friday" }
   
];


and following is my html code :

<table class="table-bordered table-striped table-responsive">
           
<thead>
           
<tr>
               
<th style="width: 150px; height: 30px;
                    background
-color: rgb(17, 124, 183);color: white; text-align: center">Day</th>
               
<th style="width: 150px; height: 30px;
                    background
-color: rgb(17, 124, 183);color: white; text-align: center"
                   
ng-repeat="c in classtimes | unique:'CLASSTIME_ID'">{{c.CLASSTIME}}</th>
           
</tr>
           
</thead>

           
<tbody>
           
<tr ng-repeat="row in routines">
               
<td style="width: 150px; height: 30px;
                                                                                                                                 background
-color: rgb(57, 111, 141); color: white; text-align: center">
                    {{row.WEEKDAY}}
               
</td>
               
<td ng-repeat="routine in routines| unique:'CLASSTIME_ID'"



                   
style="width: 150px; height: 30px;
                                                                                                                                 background
-color: rgb(0, 127, 198); color: white; text-align: center">
                   
<p ng-if="routine.CLASSTIME_ID === row.CLASSTIME_ID">{{row.COURSE_CODE}}</p>
               
</td>
           
</tr>
           
</tbody>

       
</table>

The table shows  'Sunday' data in two rows but i want to show them in one row. How can I achieve this?

Sander Elias

unread,
Jan 26, 2017, 12:37:20 AM1/26/17
to Angular and AngularJS discussion
Hi Priom,

If you make a plunk out of your code, I will take a look at it. I'm not sure I understand your issue, an example I can play with will help.

Regards
Sander
Reply all
Reply to author
Forward
0 new messages