如何让这个过滤器发挥作用?
<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/