gpt4 book ai didi

javascript - AngularJS 数组过滤器不起作用

转载 作者:行者123 更新时间:2023-12-03 05:57:20 25 4
gpt4 key购买 nike

如何让这个过滤器发挥作用?

<div ng-repeat="rvs in reviews | filter:{ Name:'{{ r.Name }}' }">
{{ rvs.Name }}
</div>

“r.Name”来自其他数组“r inrestaurants”

但是,直接输入字符串而不是 r.Name 可以,如下所示:

<div ng-repeat="rvs in reviews | filter:{ Name:'John' }">
{{ rvs.Name }}
</div>

数组文件

“评论”

{
"reviews": [
{
"Name": "Sagar Ratna",
"Reviewer": "Jaskaran",
"Comments": "Great service, healthy food!",
"Date": "25th Sept. 2016",
"Rating" : "4"
},
{
"Name": "The Night Factory",
"Reviewer": "Pawandeep",
"Comments": "Nice location, ok service!",
"Date": "29th Sept. 2016",
"Rating" : "3"
}
]
}

餐厅

{
"records": [
{
"Name": "Sagar Ratna",
"Image": "./images/sr.jpg",
"Address": "Mohali",
"Type": "South Indian",
"Hours" : "10:00-23:30"
},
{
"Name": "The Night Factory",
"Image": "./images/nf.jpg",
"Address": "Chandigarh",
"Type": "South Indian",
"Hours" : "24/7"
}
]
}

最佳答案

删除'{{}}'来自'{{r.Name}}'

<div ng-repeat="rvs in reviews | filter:{ Name:  r.Name  }">
{{ rvs.Name }}
</div>

关于javascript - AngularJS 数组过滤器不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39873538/

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