穿越foreach

时间:2016-04-18 10:45:23

标签: javascript angularjs

我收到以下API响应 -

{
    "status": 200,
    "data": {
        "430916.jpg": "abc.com/dsbfi/8/430916.jpg",
        "430917.jpg": "abc.com/dsbfi/8/430917.jpg",
        "430918.jpg": "abc.com/dsbfi/8/430918.jpg"
    },
    "error": ""
}

如何获取AngularJS中的图像路径?
解析代码是什么?

3 个答案:

答案 0 :(得分:0)

使用ng-repeat

lapply(
    SomeList,
    function(SmallList) {
        SmallList[
           order(
              sapply(
                 SmallList,
                 length
              )
           )
        ]
    }
)

答案 1 :(得分:0)

如果你想在控制器中使用angular forEach。

 angular.forEach(obj.data,function(value,key){
     console.log(value)
  })

答案 2 :(得分:0)

var response = {
  "status": 200,
  "data": {
    "430916.jpg": "abc.com/dsbfi/8/430916.jpg",
    "430917.jpg": "abc.com/dsbfi/8/430917.jpg",
    "430918.jpg": "abc.com/dsbfi/8/430918.jpg"
  },
  "error": ""
}

var images = []; //this will contain all the uri's

for(i in response.data){
 images.push(response.data[i])
}