Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-repeat nested loop

I'm looping through an array and using a filter to separate my results grouped by day. It works, but now I can't seem to access the variables inside the second loop, where I have the filter.

<ion-list class="list list-inset"  ng-repeat="(key, value) in Jobs | groupBy: 'FilterTime'">
    <div class="item item-divider"><center>{{key}}</center></div>

    <div class="list list-inset" >
        <div class="item item-divider"><center>{{JobCount}} jobs</center></div>

        <a class="item item-icon-left item-icon-right" href="#/app/viewjob/{{job.BookingPublicId}}" ng-repeat="job in value  | groupBy: 'BookingTime'">
            <i class="icon ion-android-car "></i>
            <h2>{{job.EndAddress1stLine}}</h2>
            <p>{{job.StartAddressPostCode}} <b>></b> {{job.EndAddressPostCode}}</p>

            <p ng-show="job.Status == 0"><b>Waiting</b> - {{job.BookingTime * 1000 | date:'dd-MM-yyyy hh:mm'}}</p>
            <p ng-show="job.Status == 2"><b>Accepted</b> - {{job.BookingTime * 1000 | date:'dd-MM-yyyy hh:mm'}}</p>
            <p ng-show="job.Status == 4"><b>Enroute to job</b> - {{job.BookingTime * 1000 | date:'dd-MM-yyyy hh:mm'}}</p>
            <p ng-show="job.Status == 6"><b>Waiting for customer</b> - {{job.BookingTime * 1000 | date:'dd-MM-yyyy hh:mm'}}</p>
            <p ng-show="job.Status == 8"><b>Job Started</b> - {{job.BookingTime * 1000 | date:'dd-MM-yyyy hh:mm'}}</p>
            <p ng-show="job.Status == 10"><b>Complete</b> - {{job.BookingTime * 1000 | date:'dd-MM-yyyy hh:mm'}}</p>
            <!--<span class="item-note">{{job.StartAddressPostCode}} > {{job.EndAddressPostCode}}</span>-->
            <i class="icon ion-chevron-right "></i>
        </a>
    </div>
    <!--<p>{{value.BookingPublicId}} <b>></b> {{EndAddressPostCode}}</p>-->
</ion-list>

Now, anything in job.variable doesn't load but if I do just job it'll spit out all the json.

enter image description here

As you can see, the grouping works; but I can't see any data. If I spit out just job I get this:

enter image description here

EDIT: The data looks like:

[
{
"BookingPublicId": "C1LY482T",
"BookingTime": 1462238100,
"FilterTime": "03/05/2016",
"BookingName": "",
"Status": 1,
"PassengersName": "John Smith",
"PassengersMobile": null,
"Fare": "544.13",
"StartAddressPostCode": "RG2 0GH",
"StartAddress1stLine": "Drake Way",
"EndAddressPostCode": "M90 1QX",
"EndAddress1stLine": "Drake Way",
"Status1": 1,
"Resp": "OK"
},
{
"BookingPublicId": "ZGX39WNB",
"BookingTime": 1462268100,
"FilterTime": "03/05/2016",
"BookingName": "",
"Status": 1,
"PassengersName": "John Smith",
"PassengersMobile": null,
"Fare": "544.13",
"StartAddressPostCode": "RG2 0GH",
"StartAddress1stLine": "Drake Way",
"EndAddressPostCode": "M90 1QX",
"EndAddress1stLine": "Drake Way",
"Status1": 1,
"Resp": "OK"
}
]
like image 651
MissCoder87 Avatar asked Jan 18 '26 19:01

MissCoder87


1 Answers

From your second picture it seems job is an Array not an Object so job.EndAddress1stLine wouldn't work.

If your job just contains one Object you could use something like (job[0]).EndAddress1stLine. (This also means that there might be something wrong with your data structure. You should look at it again if you have the possibility to get just an Object)

If it contains multiple Objects you would need (as mentioned in the Comments) another ng-repeat over job.

like image 188
Philipp Beck Avatar answered Jan 20 '26 20:01

Philipp Beck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!