0

在 json 响应中有以下内容:

[
   "alt_sizes":[
      {"width":500,"height":333,"url":"http://..."},  
      {"width":400,"height":266,"url":"http://..."},
      {"width":250,"height":167,"url":"http://..."},
      {"width":100,"height":67,"url":"http://..."},
      {"width":75,"height":75,"url":"http://..."}
   ]
]

我用以下方式解析我的对象

obj.alt_sizes[0]

但是如果我想用 angular.js 获得具有特定宽度或高度的元素呢?选择小的,宽度为 75 ?

4

1 回答 1

1

您可以使用过滤器过滤器来执行此操作:

$filter('filter')($scope.items, {width:'75'})

这是一个plunker:http ://plnkr.co/edit/mP3LLHgJSIEbe16HrO6f?p=preview

于 2013-11-02T00:26:36.867 回答