Daniel 976034
Daniel 976034

Reputation: 199

AngularJS: how to show an array of arrays?

I want to show an array which is formed by other arrays. This is the array:

[{
    "net": "192.168.1.1/28",
    "_id": "531d179acacc4a8115530c0e",
    "ips": [{
        "ips": "192.168.1.1",
        "_id": "531d179acacc4a8115530c0f"
    }]
}, {
    "net": "192.168.1.1/24",
    "_id": "531d1c2d857831021c48e3af",
    "ips": [{
        "ips": "192.168.1.1",
        "_id": "531d1c2d857831021c48e3b3"
    }, {
        "ips": "192.168.1.33",
        "_id": "531d1c2d857831021c48e3b2"
    }, {
        "ips": "192.168.1.38",
        "_id": "531d1c2d857831021c48e3b1"
    }, {
        "ips": "192.168.1.106",
        "_id": "531d1c2d857831021c48e3b0"
    }]
}]

I did two loops (one inside the other) with ng-repeat but the second loop doesn't show anything, do you know why? Can you help me? This is the code.

Thank you very much.

 <li ng-repeat="data in networks">
    Red <a href="#/ip/{{data._id}}">{{data.net}}</a> 
        <lu>
           <li ng-repeat="ip in data">{{ ip }}
            Red <a href="#/ip/{{ip._id}}">{{ip.ips}},,</a></li>
            </li> 
        </lu>
    </li>

Upvotes: 0

Views: 123

Answers (1)

user2033671
user2033671

Reputation:

your inner array is in data.ips so you have to iterate over that

 <li ng-repeat="ip in data.ips">

Upvotes: 3

Related Questions