How to not allow copy pasted values in ui-select in AngularJS
Asked Answered
P

1

6

I have a dropdown list and a ui-select. on the basis of dropdown value ui-select values are binding. but if i am directly pasting that specific values into ui-select it is showing as selected. how can we prevent a ui-select from copy paste values?

example is shown below.

Select Query
                    <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>
Palocz answered 2/11, 2016 at 8:53 Comment(3)
can you provide the code?Mireillemireles
Would you mind giving more details on what you are trying to achieve and what is the use case? It is a bit hard to reason why you would want to block copy paste inputChoreograph
example provided.Palocz
L
0

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

Use these kind of code.

<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>

I tried to figure out exact difference but I couldn't. But may be above sample will help you.

Lustihood answered 3/11, 2016 at 8:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.