EPV
EPV

Reputation: 61

Display nested objects from an array of objects

I have an api that returns an array of objects. within those objects there are nested objects and within those nested objects there are more nested objects. The data looks like this:

data = [{
   incident: '1',
   incidentdt: '1/1/2010',
    CriticalInc: [{
        IncidentType: '1',
        CIDT: '1/2/2010',{

   incident: '2',
   incidentdt: '1/1/2010',
    AssoINC: [{
        ASIID: '1',
        Ofc: [{
            OFC_ID: '111'}, {
            name: 'DAVE'}]},
        Ofc: [{
            OFC_ID: '121'}, {
            name: 'John'}]},  
}]

Console.log(data) will return an array of objects with nested objects. If I type in console.log(angular.toJson(data)) will return the data in JSON format.

My angular code is

<td>{{a.incident}}</td>
<td>{{a.incidentdt}}</td>
<td>{{a.IncidentType}}</td>
<td>{{a.name }}</td>

The only thing that displays is:

<td>{{a.incident}}</td>
<td>{{a.incidentdt}}</td>

The nested objects below that will not display. Please help as I do not understand how to display the nested objects.

Upvotes: 0

Views: 335

Answers (1)

Blake Mumford
Blake Mumford

Reputation: 17721

You can use dot notation to display your data. I.e.

<td>{{a.CriticalInc[0].IncidentType}}</td>

Upvotes: 1

Related Questions