Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用角度引导获取所选值';s TYPEAHEAD插件和ng更改_Javascript_Angularjs_Twitter Bootstrap_Angular Ui Bootstrap - Fatal编程技术网

Javascript 使用角度引导获取所选值';s TYPEAHEAD插件和ng更改

Javascript 使用角度引导获取所选值';s TYPEAHEAD插件和ng更改,javascript,angularjs,twitter-bootstrap,angular-ui-bootstrap,Javascript,Angularjs,Twitter Bootstrap,Angular Ui Bootstrap,为什么我不能使用ng change函数正确获取所选的typeahead值 这是我的密码 <input type="text" ng-model="asyncSelected" placeholder="Locations loaded via $http" typeahead="address for address in getLocation($viewValue)" typeahead-loading="loadingLocations"

为什么我不能使用ng change函数正确获取所选的typeahead值

这是我的密码

<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始终返回我键入的字符串,而不是通过typeahead选择的。这是plunkr,用于向您显示问题,只需键入即可。我把它从AngularUI引导的官方文档中派生出来


选择值时,可以使用“选择时提前键入”属性调用函数。试试这个:

<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)">

ah。。我错过了!!非常感谢。我花了一个小时才让它起作用