angularjs - bootstrap ui - typeahead onselect,不显示自定义值

标签 angularjs angular-ui-bootstrap typeahead

我正在尝试使用 Bootstrap 添加自动完成功能。当从自动完成列表中选择一个值时,我想在所选值的末尾附加一个“:”。由于某种原因,此附加功能不起作用。
我的 Angular html 代码是

<input type="text" ng-model="query" id="search_es"
                       typeahead="v for v in getNext($viewValue) | filter: type_filter"
                       typeahead-on-select='onSelect($item, $model, $label)'
                       autocomplete = "off"
                       placeholder="Type to search..."  />
                <div my-search-directive="search_radar"></div>

这是onSelect js代码

$scope.onSelect = function($item,$model,$label) {
      $scope.query += ": ";
}

我可以捕获另一个变量中的查询值,并可以显示在 UI 上,但显示在 Bootstrap 打字头文本框中。

我使用的是 angular1.4.7 ui-bootstrap-tpls-0.14.3.min.js

任何人都可以帮忙吗?

最佳答案

您的 $scope.onSelect 函数在此 modified ui-bootstrap example plunker 中按预期工作。我猜您发现了阻止预期行为的条件,做得很好。

关于angularjs - bootstrap ui - typeahead onselect,不显示自定义值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35497739/

相关文章:

javascript - 允许用户使用angularjs在输入框中只输入正数

angularjs - Angular JS UI Bootstrap 选项卡 (ui.bootstrap.tabs) 导致页面在选择时滚动/跳转

css - 让 col-md-4 float ,col-md-8 滚动

javascript - 如何在多个 div 元素和上下文中初始化 typeahead.js?

angularjs - AngularJS 在哪里存储缓存数据

javascript - 如何将数据添加到 Angular 返回的对象中?

javascript - Angular ng-if 与 ng-switch 性能对比

angularjs - 有没有办法在路线更改时自动关闭 Angular UI Bootstrap 模式?

angularjs - Angular Bootstrap Type Ahead 与 typeahead 语法相关的问题

elasticsearch - Typeahead/Rails : Not working