[英]AngularJS array filter not working
如何使此过滤器起作用?
<div ng-repeat="rvs in reviews | filter:{ Name:'{{ r.Name }}' }">
{{ rvs.Name }}
</div>
“ r.Name”来自其他数组“ restaurants”
但是,不是直接使用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}}'
删除'{{}}'
'{{r.Name}}'
<div ng-repeat="rvs in reviews | filter:{ Name: r.Name }">
{{ rvs.Name }}
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.