e.match is not a function
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"
}
]
+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!
Is there a solution on this issue?
+1
It would help greatly if someone can provide a demo plunkr or similar reproducing the error.
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 you must specify a tagging function on the tagging attribute as per Wiki guidance:
option description value default taggingEnable 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
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.
Thank you, @user378230
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>
tagging-label="false" fixed my issue.
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"