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

tagging function with array of string not working

Open Planet910 opened this issue 8 years ago • 4 comments
trafficstars

I want to limit the tag creation for string with length < 2 but I always get this error:

Uncaught TypeError: Cannot create property 'isTag' on string

this is the tagging function:

vm.tagging` = function (text) {
           if(!text || text.length < 2)
               return null;
           return text;
       };

and here is a plunker: http://plnkr.co/edit/SS3V4A13nAbPDRAYrdaI?p=preview

You can see the error in the console and the new tag is not created. I suppose the error is because he expect an object to be returned from that function and I return a string. I dunno how to limit the creation of tag with an array of string and I really need this.

Planet910 avatar May 05 '17 13:05 Planet910

Had a look at you plunker, i'm not getting the error or i'm doing something wrong. Can you verify if the plunker has the correct example?

Jefiozie avatar May 11 '17 06:05 Jefiozie

I verified and I still get the error. Try to write "hello" inside the input and press Enter:

  1. The tag "hello" will not be created (in fact in the dropdown it does not appear) and the first element in the dropdown is added (in my case "Red")
  2. If you open the console (F12 in chrome, tab console) you'll see the error.

Planet910 avatar May 11 '17 12:05 Planet910

I had the same issue, here is how I made it works:

<ui-select multiple tagging="myScopeFunction" (...)

with:

myScopeFunction = function(newItem) {
	return {
       label: newItem,
       value: newItem,
	}
}

It will generate the correct values in the ngModel (array of strings).

pmaoui avatar Jun 25 '18 12:06 pmaoui

Same issue here, but trying the approach suggested by @poupougnac doesn't work for me. The javascript error goes, but the value that is displayed in the dropdown list is the entire object.

mjy78 avatar Sep 17 '18 07:09 mjy78