Arrays 角度:如何过滤嵌套对象属性?
现在,普朗克: 如果对象嵌套方式如下:Arrays 角度:如何过滤嵌套对象属性?,arrays,angularjs,object,Arrays,Angularjs,Object,现在,普朗克: 如果对象嵌套方式如下: $scope.customer = { roomsclean1: { "price": 27, "title": "Room(s) to clean", "area": "6" }, roomsprotect1: { "price": 62, "title": "Room(s) to protect", "area": "0" } } 迭代每个项目并按天气返回每个属性的最佳方法是什么?嵌套
$scope.customer = {
roomsclean1: {
"price": 27,
"title": "Room(s) to clean",
"area": "6"
},
roomsprotect1: {
"price": 62,
"title": "Room(s) to protect",
"area": "0"
}
}
迭代每个项目并按天气返回每个属性的最佳方法是什么?嵌套的关键区域是否不为零
显然像
{{customer}filter:{area:“!0”}}}
这样的东西不起作用。filter接受过滤方法作为参数
您应该执行:{{customer | filter:myFilter}}
在控制器中:
$scope.myFilter = function(element) {
return element.area !== "0";
}
你的结构很奇怪。您使用的对象显然应该使用一个简单的列表。请考虑编辑您的问题,从中删除“答案”部分。如果你对你的问题有了答案,请鼓励你将其作为答案发布,而不是将其编辑到你的问题中。