获取与角引导的预输入插件和NG-改变选择的值 [英] Get selected value with Angular bootstrap's TYPEAHEAD plugin and ng-change

查看:110
本文介绍了获取与角引导的预输入插件和NG-改变选择的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我不能用NG-切换功能得到正确选择预输入值?

Why I couldn't get the selected typeahead value correctly using ng-change function ?

这是我的code

<input 
   type="text" 
   ng-model="asyncSelected" 
   placeholder="Locations loaded via $http"
   typeahead="address for address in getLocation($viewValue)" 
   typeahead-loading="loadingLocations" 
   class="form-control" 
   ng-change="change(asyncSelected)">

问题是可变的 asyncSelected 的总是返回字符串,我打字,通过预输入不选。这是给你看的问题,只是在其中键入的plunkr。从我的角度-UI-引导的官方文件

the problem is variable asyncSelected always return string that I typed, not selected via typeahead. This is the plunkr to show you the problem, just type in it. I fork it from official documentation of angular-ui-bootstrap

PLUNKR LINK这里

推荐答案

您可以使用预输入上,选择属性,当选择一个值时调用的函数。试试这个:

You can use the typeahead-on-select attribute to call a function when a value is selected. Try with this:

<input type="text" ng-model="asyncSelected" placeholder="Locations loaded via $http"
typeahead="address for address in getLocation($viewValue)" typeahead-loading="loadingLocations" 
class="form-control" typeahead-on-select="change(asyncSelected)">

这篇关于获取与角引导的预输入插件和NG-改变选择的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆