在 Angularjs 中显示独特的下拉选项

编程入门 行业动态 更新时间:2024-10-03 10:44:27
本文介绍了在 Angularjs 中显示独特的下拉选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我有一个工作正常的以下下拉菜单

I have a following drop down which is working fine

                     <select class="form-control" ng-model="cc.id">
                       <option value="">Chose Id</option>
                       <option ng-repeat="account in accounts |unique:'id'" value="{{account.id}}">{{name.id}}</option>
                       </select>

它在下拉列表中为我提供了以下选项

It gives me following options in the dropdown

          101
          101
          119
          120
          121
          121

虽然它应该只在选项中显示唯一 id 为...

While it should be only showing the unique id in options as...

       101
       119
       120
       121

Accounts 由 Account 的 jason 数组组成,它具有act_id(主键)ID名称名称位置

Accounts consists of jason array of Account which has act_id (primary key) id fname lname location

你能告诉我如何修复 id 上的唯一过滤器,以便它只显示唯一值谢谢

Can you please tell me how to fix the unique filter on id so that it displays only unique values Thanks

推荐答案

AngularUI 完全满足您的需求需要,独特的"过滤器.

AngularUI has exactly what you need, the ´unique´ filter.

示例:

ng-options="color in colors | unique:'name'"

这篇关于在 Angularjs 中显示独特的下拉选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-21 18:07:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1007862.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:选项   独特   Angularjs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!