0

AngularJS newbie here. Here is a JSON file that I've been working on and what I'm trying to do is to filter the search by ingredient using AngularJS. Help please?

{
    "id": 01,
    "recipe-name": "Fried Fish",
    "ing": {
        "i1": "1 fish",
        "i2": "1 egg",
        "i3": "1\/2 cup flour",
        "i4": "salt and pepper",
        "i5": "chili leaves"
    }
}

Here's my code for the filtered results

    <div class="results" ng-repeat="r in recipes | filter:q.ing">
1
  • You should go for custom fitler then.. Commented Jan 20, 2016 at 16:13

1 Answer 1

1

You don't need a filter.

You just need to ng-repeat through the recipes.ing nested object.

<div class="results" ng-repeat="r in recipes.ing">
    <p>{{r}}</p>
</div>

Simple fiddle: http://jsfiddle.net/zq39zspc/1/

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much for your answer!
If it solved the problem for you, please accept and vote it up :)

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.