加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – angular ui-bootstrap typeahead回调on selectMatc

发布时间:2020-12-17 09:09:08 所属栏目:安全 来源:网络整理
导读:我使用的角度ui-bootstrap typeahead,我想使用它作为一种方式来拾取许多选择,所以我需要得到选择的值,当selectMatch方法启动,但我不能找到如何做那在我的控制器 div class='container-fluid' ng-controller="TypeaheadCtrl"preModel: {{selected| json}}
我使用的角度ui-bootstrap typeahead,我想使用它作为一种方式来拾取许多选择,所以我需要得到选择的值,当selectMatch方法启动,但我不能找到如何做那在我的控制器
<div class='container-fluid' ng-controller="TypeaheadCtrl">
<pre>Model: {{selected| json}}</pre>
<input type="text" ng-model="selected" typeahead="state for state in states | filter:$viewValue">

如果我观看选择的值,我每次按下一个键时都有变化…

scope.$watch('selected',function(newValue,oldValue) {... });

我得到的方法selectMatch是一个被调用时,用户按enter或单击列表,但我不知道如何有一个回调的那个…

谢谢 !

现在有更好的方法这样做。 A new callback method has been added

在控制器文件中添加如下内容:

$scope.onSelect = function ($item,$model,$label) {
    $scope.$item = $item;
    $scope.$model = $model;
    $scope.$label = $label;
};

在视图中添加以下内容:

<input type="text"
        ng-model="selected"
        typeahead="state for state in states | filter:$viewValue"
        typeahead-editable="false"
        typeahead-on-select="onSelect($item,$label)"/>

有关详细信息,请参阅typeahead spec(搜索onSelect)。

检查以下网址是否有帮助
http://www.techguides.in/how-to-create-autocomplete-using-angularjs-ui/

http://www.techguides.in/how-to-customize-autocomplete-to-display-multiple-columns-using-angularjs-ui-2/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读