从下拉列表中选择一个项目后,每次按键都会触发错误:origItem.toUpperCase 不是函数
,请参阅 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>
标签
在哪里
$scope.tags = [
{
name: 'foo'
},
{
name: 'bar'
}
]
我没有找到任何有关使用对象作为下拉列表源的信息 - 但我似乎做错了。
最佳答案
我检查了这个,这对我解决问题很有帮助。 1. 给你的 demo.js 添加一个函数
$scope.tagTransform = function (newTag) {
var item = {
name: newTag
};
return item;
}
2。然后像这样将函数添加到标记标签中。
tagging="tagTransform"
当我添加这个时,我没有再在你的 plunker 上收到错误。 希望这会奏效。
关于javascript - UI 选择的对象源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38294715/