ui-select icon indicating copy to clipboard operation
ui-select copied to clipboard

e.match is not a function

Open joelcdoyle opened this issue 11 years ago • 11 comments

Using tagging, when I enter text into the text input, I get this dev console error once for every character I enter in the input:

Uncaught TypeError: e.match is not a function

The select is working properly, but what is this annoying error?

<ui-select multiple tagging="tagTransform"
                  ng-disabled="disabled"
                  search-enabled="true"
                  tagging-label="(custom 'new' label)" 
                  theme="bootstrap"
                  sortable="true" 
                  title="Choose a category"
                  id="add-categories" 
                  ng-model="transaction.selected">
  <ui-select-match placeholder="Enter category title and press enter..." >
    {{$item.description}}
  </ui-select-match>
  <ui-select-choices repeat="category in categories | filter:$select.search">
    <span ng-bind-html="category.description | highlight: $select.search"></span>
  </ui-select-choices>
</ui-select>
$scope.categories = [
 {
    code: 50,
    description: "Gas"
 },
 ...
 {
   code: 100,
   description: "Utilities"
 }
]

joelcdoyle avatar Jul 20 '15 20:07 joelcdoyle

+1

I don't have time to look into this right now, but I'm pretty sure it's expecting the model to be a string, and if you are using a complex object {name: "foo", id: 123155}, .match is undefined because it's the wrong data type. Since it's inexplicably working even with this error, I'm not too concerned, but red text in the console is always bothersome!

dcjohnston avatar Jul 22 '15 15:07 dcjohnston

Is there a solution on this issue?

curtis-arch avatar Feb 17 '16 22:02 curtis-arch

+1

ghost avatar Feb 24 '16 10:02 ghost

It would help greatly if someone can provide a demo plunkr or similar reproducing the error.

user378230 avatar Mar 16 '16 13:03 user378230

https://embed.plnkr.co/OLkILVt02vBFhonBPExD/ Please try to search something it looks, that item.id is not a string, so doesn't have match method

AnatoliyLitinskiy avatar Mar 18 '16 15:03 AnatoliyLitinskiy

@AnatoliyLitinskiy you must specify a tagging function on the tagging attribute as per Wiki guidance:

option description value default
tagging Enable tagging mode (add new items on the fly). Accepts a string which is a scope function. If your model is an array of objects, this string is required. The function will be passed the new item as a string and should return an object which is the transformed value to be pushed to the items array. string ($scope function) undefined

user378230 avatar Mar 20 '16 20:03 user378230

Going to close as this seems like a usage issue - feel free to open a new issue if this is not the case with appropriate reproduction.

wesleycho avatar Mar 27 '16 23:03 wesleycho

Thank you, @user378230

AnatoliyLitinskiy avatar Apr 04 '16 08:04 AnatoliyLitinskiy

I had same problem. But i fixed when the attribute taggin-lable set to false

<ui-select multiple tagging tagging-label="false"
      on-select="vm.addTag(task.id,$item)" on-remove="vm.removeTag(task.id,$item)"
      ng-model="task.etiquetas" theme="bootstrap" style="width: 100%;text-align: left;"
      title="{{vm.appData.introduceEtiqueta_label}}">
        <ui-select-match placeholder="{{vm.appData.add_label}}">{{$item.nombre}}</ui-select-match>
        <ui-select-choices repeat="tag in vm.availableTags | filter:$select.search"
        refresh="vm.refreshTagSearh($select.search);"
        refresh-delay="700">
        {{tag.nombre}}
      </ui-select-choices>

samuelzyx avatar May 12 '17 16:05 samuelzyx

tagging-label="false" fixed my issue.

swatijoshi avatar Aug 08 '17 14:08 swatijoshi

I also run into this issue, and I just wanna share to you guys how I fixed it.

For <ui-select-choices>, the value to provide should be array of strings and NOT array of objects. The javascript's .match() method is intended for String.

I also provided tagging and tagging-label =" (New)" to fix other issues related to close-on-select="false"

arjuneyy avatar Mar 14 '18 11:03 arjuneyy