0

Array 1: Categories -> Category_Name, Category_Id

Array 2: Items -> Item_name ... etc , Category_Belonging_Id

I need to filter shown items based on selected category.

<div class="list>
    <select>
       <option ng-repeat="category in categories" ng-model="category_type">
          {{category.Category_Name}}
       </option>
    </select>

<a ng-repeat="item in items | filter: // What should I put here?" href="#">

...

</a>

</div>
1
  • can you share this issue on jfiddle Commented Mar 28, 2016 at 8:42

3 Answers 3

1

first of all you should use ng-option instead of ng-repeat like

<select ng-model="category_type" ng-options="category.Category_Name for category in categories"></select>

and use filter like

filter:{Category_Belonging_Id:category_type.Category_Id }

see demo here

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

Comments

1

Assuming you have:

Catergory = {
id 
name
}

and

MeatType{
    id
    catergoryId
    name
    }

You can do something like

<a ng-repeat="item in meatTypes | filter: {categoryId : catergory_type.id}" href="#">

1 Comment

Sorry for misunderstanding the MeatTypes refers to Items.. I've edited my question. You say category_type.id but I assume you mean category_type.Category_Id. Right ??
0

Try this

<a ng-repeat="item in meatTypes | filter: {Category_Belonging_Id:category_type.Category_Id }"   href="#">

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.