nehalist
nehalist

Reputation: 1496

Object source for UI select

After selecting an item from the dropdown an error is triggered for every keypress: origItem.toUpperCase is not a function, see http://plnkr.co/edit/xxTfWMcK3CuRPuiRldcB?p=preview

My ui select element:

<ui-select multiple tagging tagging-label="(custom 'new' label)" ng-model="project.tags" theme="bootstrap" sortable="true" title="Tags">
      <ui-select-match placeholder="Tags">{{$item.name || $item}}</ui-select-match>
      <ui-select-choices repeat="tag in tags | filter:$select.search">
        {{tag.name || tag}}
      </ui-select-choices>
    </ui-select>

where tags is

$scope.tags = [
 {
   name: 'foo'
 },
 {
   name: 'bar'
 }
]

I didn't find anything about using an object as source for the dropdown - but it seems like I'm doing it wrong.

Upvotes: 1

Views: 195

Answers (1)

Jefiozie
Jefiozie

Reputation: 133

I check this and this worked for me to resolve the issue. 1. Add a function to your demo.js

$scope.tagTransform = function (newTag) {
var item = {
    name: newTag
 };

 return item;
}

2. Second add the function to the tagging tag like so.

 tagging="tagTransform" 

I didn't get the error any more on your plunker when I added this. Hope this will work.

Upvotes: 3

Related Questions