2016-03-28 142 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="#">