简体   繁体   中英

eliminate duplicates in the drop down menu using angular ui unique

hi i have an api that takes its value from db. 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. And i have to do it with angular js since all the functionalities are based on angular 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. Find it here: http://angular-ui.github.io/

You can use it like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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