简体   繁体   English

使用angular ui unique消除下拉​​菜单中的重复项

[英]eliminate duplicates in the drop down menu using angular ui unique

hi i have an api that takes its value from db. 嗨,我有一个从db获取其值的api。 In my api i have a drop down -menu and i have certain categories like food , healthcare and in the drop down the categories gets repeated what should i do to make the drop down categories unique. 在我的api我有一个下拉菜单,我有一些类别,如食品,医疗保健和下拉类别重复我应该做什么使下拉类别独特。 And i have to do it with angular js since all the functionalities are based on angular js. 我必须使用角度js,因为所有功能都基于角度js。

<div class="span3">
    <div class="input-append">
        <input class="span2" id="brandSearch" data-ng-model="brand" type="text" placeholder="Search">
        <div class="btn-group">
            <button class="btn dropdown-toggle" data-toggle="dropdown">
                Brand
                <span class="caret"></span>
            </button>
            <ul class="dropdown-menu">
                   <div id="divBrandId{{$index+1}}" ng-repeat="coupon in coupons | filter" onclick="javascript:assignTextValueBrand('{{$index+1}}');" onmouseover="this.style.background='violet';this.style.color='white';" onmouseout="this.style.background='white';this.style.color='black';"> {{xxxx.brand}}
                   </div>
            </ul>
        </div>
    </div>
</div>

Angular-UI has a "Unique" filter that you can use to do this. Angular-UI有一个“唯一”过滤器,您可以使用它来执行此操作。 Find it here: http://angular-ui.github.io/ 在这里找到它: http//angular-ui.github.io/

You can use it like this: 你可以像这样使用它:

<div ng-repeat="coupon in coupons | unique:'brand'">
   {{coupon.brand}}
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM