更新时间:2023-02-26 09:46:47
现在有这样做的更好的方法。 新回调方法添加
There is better way of doing this now. A new callback method has been added
在控制文件中添加以下内容:
In controller file add the following:
$scope.onSelect = function ($item, $model, $label) {
$scope.$item = $item;
$scope.$model = $model;
$scope.$label = $label;
};
在视图中添加以下内容:
In view add the following:
<input type="text"
ng-model="selected"
typeahead="state for state in states | filter:$viewValue"
typeahead-editable="false"
typeahead-on-select="onSelect($item, $model, $label)"/>
查看typeahead SPEC 了解更多的信息(搜索ONSELECT)。
See the typeahead spec for more information (search for onSelect).
检查一下下面的网址帮助
http://www.techguides.in/how-to-create-autocomplete-using-angularjs-ui/
Check out if the following URLs helps 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/