【问题标题】:angular ui - select: tagging without multiple - why isn't this working?角度用户界面 - 选择:没有多个标签 - 为什么这不起作用?
【发布时间】:2015-05-25 20:23:27
【问题描述】:

我使用以下软件包

$ bower list
bower check-new     Checking for new versions of the project dependencies..
(...)
├── angular#1.3.15 (1.3.16-build.113+sha.3881831 available, latest is 1.4.0-rc.2)
├─┬ angular-resource#1.3.15 (1.3.16-build.113+sha.3881831 available, latest is 1.4.0-rc.2)
│ └── angular#1.3.15 (latest is 1.4.0-rc.2)
├─┬ angular-route#1.3.15 (1.3.16-build.113+sha.3881831 available, latest is 1.4.0-rc.2)
│ └── angular#1.3.15
├─┬ angular-sanitize#1.3.15 (1.3.16-build.113+sha.3881831 available, latest is 1.4.0-rc.2)
│ └── angular#1.3.15
├─┬ angular-ui-select#0.11.2
│ └── angular#1.3.15 (1.4.0-rc.2 available)
├─┬ bootstrap#3.3.4
│ └── jquery#2.1.4
├── jquery#2.1.4
├── modernizr#2.8.3
└── normalize.css#3.0.3

我有这个 angular-ui-select 代码

<ui-select
        tagging="createTag"
        ng-model="needs_ingredient.ingredient"
        theme="bootstrap"
        ng-disabled="disabled"
        title="Zutat auswählen">
    <ui-select-match placeholder="Zutat auswählen...">
        {{$select.selected.name}}
    </ui-select-match>
    <ui-select-choices repeat="ingredient in ingredients | filter: {name: $select.search}">
        <div ng-if="ingredient.isTag" ng-bind-html="ingredient.name +' <small>(hinzufügen)</small>'| highlight: $select.search"></div>
        <div ng-if="!ingredient.isTag" ng-bind-html="ingredient.name + ingredient.isTag | highlight: $select.search"></div>
    </ui-select-choices>
</ui-select>

成分列表的一个元素看起来像这样

{
    "id": 123,
    "name": "xyz"
},

这部分js代码为列表创建新对象

$scope.createTag = function (newTag) {
    console.log('createTag');

    return {
        id: null,
        name: newTag
    };
};

我希望这是一个列表,我可以在其中选择一个项目或添加一个新项目,但它不起作用。

错在哪里?没有多选的标记不起作用吗?

【问题讨论】:

    标签: javascript angularjs angular-ui angular-ui-select


    【解决方案1】:

    你可以设置:

    tagging-label="false"
    

    在 ui-select 标记中。

    它对我有用!

    【讨论】:

    • taggingLabel:为出现在下拉列表中的标签设置标签。
    【解决方案2】:

    我在 angular-ui 的 github 上发现了这个问题。

    有人发布了临时解决方法

    https://github.com/angular-ui/ui-select/issues/890

    【讨论】:

      【解决方案3】:

      供日后参考,

      您可以通过设置使其单选

          taggingLabel to false.
      

      在指令中

      【讨论】:

      • -1 taggingLabel:Set a label for tags that appear in the dropdown. source
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-31
      • 1970-01-01
      相关资源
      最近更新 更多