【问题标题】:How to clear selected value in angular-ui select2如何清除angular-ui select2中的选定值
【发布时间】:2014-10-07 12:10:35
【问题描述】:

我正在使用 angular-ui select2 插件,我找不到任何解决方案来清除所选输入。如何清除选定的输入?谢谢。

<http://plnkr.co/edit/a3KlK8dKH3wwiiksDSn2?p=preview>

我想要这样的东西。

【问题讨论】:

    标签: angularjs angular-ui ui-select2


    【解决方案1】:

    这里有两个选项:

    1 - 你可以使用标准属性allow-clear="true"

      <ui-select ...>
        <ui-select-match allow-clear="true" ...>{{$select.selected.name}}</ui-select-match>
        ...
      </ui-select>
    

    2 - 你可以添加一个按钮

    <ui-select-match placeholder="Select or search a country in the list...">
      <span>...</span>
      <button class="clear" ng-click="clear($event)">X</button>
    </ui-select-match>
    
    $scope.clear = function($event) {
       $event.stopPropagation(); 
       $scope.country.selected = undefined;
    };
    

    【讨论】:

      猜你喜欢
      • 2014-12-26
      • 2014-12-10
      • 1970-01-01
      • 2012-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-29
      • 2020-04-07
      相关资源
      最近更新 更多