如何使用自定义属性过滤我的下拉指令?
$scope.myKeyword = [
{Id: 1, Keyword:"ActivityType", Description: "Active"},
{Id: 2, Keyword:"ActivityType", Description: "InActive"},
{Id: 3, Keyword:"ActivityType", Description: "Deleted"},
{Id: 4, Keyword:"MarketSegment", Description: "Fashion"},
{Id: 5, Keyword:"MarketSegment", Description: "IT"},
{Id: 6, Keyword:"MarketSegment", Description: "F&B"},
{Id: 7, Keyword:"MarketSegment", Description: "Manufacturing"},
];
指令标记
<keywords supplier-id="supplier.Id" keyword-type="MarketSegment" title="Choose Status" label="" array="myKeyword" opt-value="Id" opt-description="Description"></keywords>
我想通过提供的MarketSegment过滤下拉列表。
答案 0 :(得分:1)
我找到了解决方案,只需在指令模板中添加filter:keywordType即可。这是更新link
<select ng-model="supplierId" ng-options="a[optValue] as a[optDescription] for a in array | filter: keywordType" required>'