UI 选择的对象源

Object source for UI select

本文关键字:对象 选择 UI      更新时间:2023-09-26

从下拉列表中选择一个项目后,每次按键都会触发错误:origItem.toUpperCase is not a function,请参阅 http://plnkr.co/edit/xxTfWMcK3CuRPuiRldcB?p=preview

我的用户界面选择元素:

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

tags在哪里

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

我没有找到任何关于使用对象作为下拉列表源的信息 - 但似乎我做错了。

我检查了一下,这对我解决了这个问题。1. 向演示添加函数.js

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

2.第二次像这样将功能添加到标记标签中。

 tagging="tagTransform" 

当我添加这个时,我没有在你的 plunker 上再也没有收到错误。希望这会起作用。