【问题标题】:Is there any way to choose ui-select-search value if there is no value in select?如果选择中没有值,有什么方法可以选择 ui-select-search 值?
【发布时间】:2019-03-09 18:39:58
【问题描述】:

我正在使用ui-select 而不是本机选择。这就是问题所在:

用户可以在位置数组中选择取货地址。如果没有地址,那么他可以添加新地址。如果在 ui-select-choices 中没有搜索词,我想使用 ui-select-search 输入字段来过滤选择并添加新的 uniq 地址。有什么办法可以做到吗?

这是我的代码:

<ui-select
    ng-model="order.return_address"
    theme="bootstrap"
    tagging="order.return_address"
    tagging-label="false"
    reset-search-input="false"
    on-select="itemSelected($select.selected)"
    ng-required="isRequired"
    refresh="updateValue('pick_up', $select.search)"
    refresh-delay="900"
    name="pick-up-location">
    <ui-select-match>{{ $select.selected.title }}</ui-select-match>
    <ui-select-choices repeat="address in pickUpAddresses | filter: {title: $select.search}" refresh="refreshItems($select.search)" refresh-delay="700">
        {{ address.title }}
    </ui-select-choices>
</ui-select>

附:我不想看到我在 pickUpAddresses 数组的输入字段中写入的地址。

【问题讨论】:

    标签: angularjs ui-select


    【解决方案1】:

    有一种方法可以完成这项工作。因此,我需要将输入字段放置在与选择相同的位置并添加到两个透明背景中。当您搜索时,如果您从 ui-select-choices 中选择某些内容,则没有问题。当您搜索时,如果 ui-select-choices 中没有项目,则将此属性添加到 ui-select reset-search-input="false" 中,这将保存输入的值。现在,您只需要从输入中获取值,该值是$select.search,然后您可以在同一视图中选择和输入。此外,如果您选择了某些内容,则需要重置 $select.search;如果您选择 input insted of select,则需要重置 $select.selected

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多