在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?
答案 0 :(得分:1)
您可以使用过滤器过滤器执行此操作:
$filter('filter')($scope.items, {width:'75'})