gpt4 book ai didi

Angularjs 过滤器嵌套对象

转载 作者:行者123 更新时间:2023-12-02 22:44:39 25 4
gpt4 key购买 nike

我有这样的 Angular 嵌套对象。有没有办法过滤它的嵌套属性

<li ng-repeat="shop in shops | filter:search">
search.locations.city_id = 22

我只显示父元素,但想按这两个元素进行过滤,例如:

search = 
category_id: 2
locations:
city_id: 368

[
name: "xxx"
category_id: 1
locations: [
city_id: 368
region_id: 4
,
city_id: 368
region_id: 4
,
city_id: 368
region_id: 4
]
,
name: "xxx"
category_id: 2
locations: [
city_id: 30
region_id: 4
,
city_id: 22
region_id: 2
]
]

最佳答案

您也可以这样过滤(版本1.2.13+)

<li ng-repeat="shop in shops | filter: { locations: [{ city_id: search.locations.city_id }] }">

关于Angularjs 过滤器嵌套对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18504779/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com