UI select 的对象源
Object source for UI select
在 select 从下拉列表中输入一个项目后,每次按键都会触发错误:origItem.toUpperCase is not a function
,请参阅 http://plnkr.co/edit/xxTfWMcK3CuRPuiRldcB?p=preview
我的uiselect元素:
<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. 给你的 demo.js
添加一个函数
$scope.tagTransform = function (newTag) {
var item = {
name: newTag
};
return item;
}
2。其次像这样将函数添加到标记标签中。
tagging="tagTransform"
当我添加这个时,我在你的 plunker 上没有再收到错误。
希望这会奏效。
在 select 从下拉列表中输入一个项目后,每次按键都会触发错误:origItem.toUpperCase is not a function
,请参阅 http://plnkr.co/edit/xxTfWMcK3CuRPuiRldcB?p=preview
我的uiselect元素:
<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. 给你的 demo.js
添加一个函数$scope.tagTransform = function (newTag) {
var item = {
name: newTag
};
return item;
}
2。其次像这样将函数添加到标记标签中。
tagging="tagTransform"
当我添加这个时,我在你的 plunker 上没有再收到错误。 希望这会奏效。