AngularJS:如何显示数组数组?

时间:2014-03-10 16:03:26

标签: javascript arrays angularjs

我想显示一个由其他数组组成的数组。这是数组:

[{
    "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"
    }]
}]

我用ng-repeat做了两个循环(一个在另一个里面)但是第二个循环没有显示任何东西,你知道为什么吗?你能帮助我吗?这是代码。

非常感谢。

 <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>

1 个答案:

答案 0 :(得分:3)

你的内部数组在data.ips,所以你必须迭代

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