javascript - 如何不允许在 AngularJS 的 ui-select 中复制粘贴值

标签 javascript jquery angularjs angular-ui angular-ui-select

我有一个下拉列表和一个ui-select。基于下拉值 ui-select 值是绑定(bind)的。但如果我直接将该特定值粘贴到 ui-select 中,它就会显示为选中状态。 我们如何防止 ui-select 复制粘贴值?

示例如下所示。

选择查询
                    <div class="dropdown-Finding">
                        <ui-select class="form-control dropdown-reviwerFinding-select" id="searchBarArea" onkeypress="return false;" multiple tagging tagging-label="false" ng-model="QiReviewerFindingType.selectedItems" theme="bootstrap">
                            <ui-select-match placeholder="Select Reviewer Findings">{{$item.ShortDescription}}</ui-select-match>
                            <ui-select-choices repeat="qiQueryFinding in qiQueryFindings | filter:$select.search">
                                {{qiQueryFinding.ShortDescription}}
                            </ui-select-choices>
                        </ui-select>
                        <span class="carat" open-menu-by-click="searchBarArea"></span>
                    </div>

最佳答案

http://plnkr.co/edit/BVaXpviCACi5sd3aw9oX?p=preview

使用这些代码。

<ui-select ng-model="ctrl.person.selected" theme="select2" on-select="ctrl.onSelectCallback($item, $model)" ng-disabled="ctrl.disabled" style="min-width: 300px;" title="Choose a person">
<ui-select-match placeholder="Select a person in the list or search his name/age...">{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="person.email as person in ctrl.people | propsFilter: {name: $select.search, age: $select.search}">
  <div ng-bind-html="person.name | highlight: $select.search"></div>
  <small>
    email: {{person.email}}
    age: <span ng-bind-html="''+person.age | highlight: $select.search"></span>
  </small>
</ui-select-choices>

我试图找出确切的区别,但我做不到。但上面的示例可能会对您有所帮助。

关于javascript - 如何不允许在 AngularJS 的 ui-select 中复制粘贴值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40375764/

相关文章:

javascript - ES6 从对象中获取随机元素,不重复

javascript - 如何清除过滤器 - AngularJS

javascript - Firebug "XML cannot be the whole program"错误消息是什么意思?

javascript - 单击一次后如何禁用提交按钮以防止在 Angularjs 中多次提交?

javascript - Meteor - 在模板加载时将类添加到 DOM 元素

javascript - 我正在尝试根据更改选择器使用 on() 附加事件

javascript - 如何将数组值传递给javascript函数? PHP Laravel

javascript - 添加新联系人的指令

javascript - 在所有数据都存在之前,如何防止 Angular 渲染页面?

javascript - 我想通过js在获取的数据上显示隐藏数据