Javascript 使用角度引导获取所选值';s TYPEAHEAD插件和ng更改
为什么我不能使用ng change函数正确获取所选的typeahead值 这是我的密码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"
<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。。我错过了!!非常感谢。我花了一个小时才让它起作用