Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a set of JSON data and within it, i am trying to calculate the length of an array (Infos):

My JSON:

    "Association": {
    "Items": [
         {
            "AssocName": {
                "SurName": "BLOGGS",
                "Title": "MR",
                "ForeName": "HAPPY"
            },
            "Details": [
                {
                  "Name": {
                        "SurName": "BLOGGS",
                        "Title": "MR",
                        "ForeName": "HAPPY"
                    },
                   "Infos": [
                      {
                         //Some Data
                         //Some Data
                         //Some Data
                      },
                      {
                         //Some Data
                         //Some Data
                         //Some Data
                      },
                      {
                         //Some Data
                         //Some Data
                         //Some Data
                      },
                      {
                         //Some Data
                         //Some Data
                         //Some Data
                      }
                    ]
                 }
             ]
        },
        {
            "AssocName": {
                "SurName": "BLOGGS",
                "Title": "MRS",
                "ForeName": "BLUE"
            },
            "Details": [
                {
                  "Name": {
                        "SurName": "BLOGGS",
                        "Title": "MRS",
                        "ForeName": "BLUE"
                    },
                   "Infos": [
                      {
                         //Some Data
                         //Some Data
                         //Some Data
                      },
                      {
                         //Some Data
                         //Some Data
                         //Some Data
                      }                     
                   ]
               }
            ]
        }
    ]
}

My HTML:

<tr ng-repeat-start="associations in Association.Items track by $index">
    <td>
        {[{associations.AssocName.Title}]}
        {[{associations.AssocName.ForeName}]}
        {[{associations.AssocName.SurName}]}
    </td>
    <td>
        {[{ associations[$index].Details.Infos.length }]} of Details
    </td>
</tr>

But no valus seems to be displayed... The Title, Forename and Surname are displaying as expected.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Just try out this way as shown below

Working Demo

<table>
<tr ng-repeat="associations in Association.Items">
    <td>
        {{associations.AssocName.Title}}
        {{associations.AssocName.ForeName}}
        {{associations.AssocName.SurName}}
    </td>
    <td>
        [{{associations.Details[0].Infos.length}}] of Details
    </td>
</tr>
</table>
share|improve this answer
    
This is working - thank you. –  Oam Psy Sep 1 '14 at 13:57

You don't need index

<tr ng-repeat-start="associations in Association.Items">
    <td>
        {[{associations.AssocName.Title}]}
        {[{associations.AssocName.ForeName}]}
        {[{associations.AssocName.SurName}]}
    </td>
    <td>
        {[{ associations.Details.Infos.length }]} of Details
    </td>
</tr>
share|improve this answer
    
tried that, nothing is displayed. –  Oam Psy Sep 1 '14 at 13:22
    
@Blackhole - this answer was missing [0] from Details... See Nidhish's answer. –  Oam Psy Sep 1 '14 at 13:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.