如何使用typehead在文本框中只返回相等的名称。我不明白typehead中使用的参数是什么,你能帮我吗?当您键入字符或字母时,文本框上不显示。以下是示例代码和数据。
HTML:
<input type="text" name="selectbiller" ng-model="vm.selectedBiller"
uib-typeahead="item as items.Name for items in vm.onNameEntry($viewValue)"
typeahead-editable="false"
typeahead-on-select="vm.onCarSelect($item, $model, $label)"
placeholder="Search a Car"
autocomplete="off"/>AngularJs:
vm.onNameEntry = function(name) {
return carService.searchCarByName({name: name})
.$promise
.then(function (data) {
if (data && data.Items) {
return data.Items;
}
return null;
});
}数据:
from,console.log(数据);
Value:Array(8)
0:{Id: null, Name: "Innova"}
1:{Id: null, Name: "Ferrari"}
2:{Id: null, Name: "BMW"}
3:{Id: null, Name: "Toyota"}
4:{Id: null, Name: "Honda"}
5:{Id: null, Name: "Hyuindai"}
6:{Id: null, Name: "Kia"}
7:{Id: null, Name: "Suzuki"}发布于 2017-11-06 15:24:58
尝尝这个
uib-typeahead="item as item.Name for item in vm.onNameEntry($viewValue) | filter:{Name:$viewValue}"下面是一个可以满足您需求的jsfiddle示例。http://jsfiddle.net/harshakj89/gfbeLbke/1/
发布于 2017-11-06 14:56:50
items应为item,因为vm.onNameEntry($viewValue)返回项目列表
uib-typeahead="item as item.Name for item in vm.onNameEntry($viewValue)"https://stackoverflow.com/questions/47130945
复制相似问题