首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ui-select鼠标选择在标记时不起作用-label=false

ui-select鼠标选择在标记时不起作用-label=false
EN

Stack Overflow用户
提问于 2016-02-22 19:24:43
回答 1查看 839关注 0票数 1

在Angular ui-select中使用tagging-label='false'时,无法通过鼠标单击进行选择。我测试了angular-ui-select - 0.13.2、0.14.1和最新版本0.14.9。我的要求是我可以通过键盘输入任何值,就像文本框一样,我可以用鼠标从下拉菜单中选择任何现有的选项。

代码语言:javascript
复制
 <ui-select tagging="newTag" tagging-label="false" ng-model="selectedCountry" theme="bootstrap" style="width: 300px;" title="Choose a country">
      <ui-select-match placeholder="Select country...">{{$select.selected}}</ui-select-match>
      <ui-select-choices repeat="country in countries | filter:$select.search">
      {{country}}
      </ui-select-choices>
 </ui-select>

这里是Plnkr - http://plnkr.co/edit/UGbBq1fSMZK12tpa2wK5?p=preview

EN

回答 1

Stack Overflow用户

发布于 2016-02-22 21:00:41

我认为问题出在tagging="newTag"属性中,该属性需要定义一个$scope.newtag()函数(但您的控制器中缺少该函数)。

它可以像下面这样修改代码:

代码语言:javascript
复制
  <ui-select ng-model="model.selectedCountry" tagging-label="false" theme="bootstrap" ng-disabled="disabled" style="width: 300px;" title="Choose a country">
    <ui-select-match placeholder="Select country...">{{$select.selected}}</ui-select-match>
    <ui-select-choices repeat="country in countries | filter:$select.search">
      {{country}}
    </ui-select-choices>
  </ui-select>

另一件事是,由于scope inheritance in Angular/JS,有必要将selectedCountry包装在对象中(所有ui选择示例都使用这种方式):

代码语言:javascript
复制
 $scope.model = {selectedCountry: ''};

plnkr更新:

http://plnkr.co/edit/wqyTifycfTmnnsn22Be9?p=preview

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35552360

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档