2016-03-28 86 views
0

阵列1:分类 - > CATEGORY_NAME,CATEGORY_ID基于选择列表上应用过滤器 - 角JS

阵列2:物品 - > ITEM_NAME ...等,Category_Belonging_Id

我需要过滤根据显示的项目选定的类别。

<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> 
+0

你可以jfiddle – vineet

回答

1

首先你应该使用ng-option代替ng-repeat

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

,并使用filter

filter:{Category_Belonging_Id:category_type.Category_Id } 

see demo here

1

假设你有:

Catergory = { 
id 
name 
} 

MeatType{ 
    id 
    catergoryId 
    name 
    } 

你可以做这样的事情

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

对不起分享这个问题的误解MeatTypes指项目..我编辑了我的问题。你说category_type.id,但我认为你的意思是category_type.Category_Id。对 ?? – Korte

0

试试这个

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