根据 select 列表应用过滤器 - Angular JS

Apply filter based on select list - Angular JS

数组 1:类别 -> Category_Name、Category_Id

数组 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>

假设你有:

Catergory = {
id 
name
}

MeatType{
    id
    catergoryId
    name
    }

你可以这样做

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

试试这个

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

首先你应该使用 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