0

How can I make the this filter work?

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

'r.Name' comes from other array "r in restaurants"

However, instead of r.Name directly putting the string works, like this:

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

Array Files

'reviews'

{
  "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"
    }
  ]
}

Restaurants

{
  "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"
    }
  ]
}
4
  • Can you place here your both array reviews and r ?? Commented Oct 5, 2016 at 12:09
  • When you are inside angular tag, you don't need to use mustaches {{}}. Try only filter:{ Name:' r.Name '} Commented Oct 5, 2016 at 12:11
  • @VaibhavPatil updated! Commented Oct 5, 2016 at 12:12
  • @LucasCosta no success! Commented Oct 5, 2016 at 12:13

1 Answer 1

1

Remove '{{}}' from '{{r.Name}}'

<div ng-repeat="rvs in reviews | filter:{ Name:  r.Name  }">
 {{ rvs.Name }}
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.