Problem with collection-repeat on ion-item from JSON data


#1

Hi guys, I am now trying to display data from a JSON data on an ion-list.
I have tried to use “ng-repeat” and “collection-repeat” to present those data and they are not working.

I am not sure if it is because my complex JSON structure, it is like:

{

"items":[
    {
        "username":"abc",
        "orderID":"1234",
        "commentHistory":[
            {
                "comment":"Comment Date: 2016/12/09 13:44:23"
            },
            {
                "comment":"Failed: 2016/12/08 11:42:12"
            }
        ],
        .........
    }
]}

Most of the example I saw on web are only containing a single array for the JSON, but now I am having a few arrays for the json, i am not so sure how to write to code to access those data, like, should I write {{items.commentHistory.comment}} or {{items[].commentHistory[].comment}} ??

Also, I was thinking if there is any questions of my javascript. So I would like to ask how should I write the controller to get the JSON file such that its data can be accessed?

Moreover, I was trying to get the JSON data to a ion-list, if I want to click on an ion-item on the list, and to display its detailed information in another column? In what way I should do that, is it enough to use “ng-show” or “ng-hide” for it?

It would be grateful if you can provide me some directions. Thank you for your time to read my question.

Best regards,
ITDog


#2

There is no ng-repeat in ionic2. If you are using ionic 1.x then why did you mention ionic2.

However, how do you want to present the list?


#3

Sorry mark, I am new to ionic and I thought I am using Ionic2, but actually my version is 1.3.2.

http://play.ionic.io/app/245cb314b470
I want to present the list similar to this one, but in an “ion-list”+“ion-item” form.
I have tried just now these code are working to be ion-item, but only if my array are not nested like what I have mentioned previously. These code only works when there is only one array in javascript.