【问题标题】:Object source for UI selectUI 选择的对象源
【发布时间】:2016-07-14 22:51:22
【问题描述】:

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

我的 ui 选择元素:

<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'
 }
]

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

【问题讨论】:

    标签: javascript angularjs ui-select


    【解决方案1】:

    我检查了这一点,这对我解决问题很有用。 1. 在你的 demo.js 中添加一个函数

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

    2。其次像这样将函数添加到标记标签中。

     tagging="tagTransform" 
    

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

    【讨论】:

      猜你喜欢
      • 2016-07-02
      • 1970-01-01
      • 2013-05-29
      • 2021-07-23
      • 2013-11-25
      • 1970-01-01
      • 2017-12-24
      • 2018-11-20
      • 1970-01-01
      相关资源
      最近更新 更多