[英]How can i bind object to value of ngx-typehead?
i have this array:我有这个数组:
let cityArrays = [
{
"zip": "60645",
"city": "Chicago / IL",
"longitude": "42.008956",
"latitude": "-87.69634"
},
{
"zip": "60647",
"city": "Chicago / IL",
"longitude": "41.921126",
"latitude": "-87.70085"
},
}
How can i show all of the cities in the typehead,but when the value is selected one city, then to get the whole object on typeaheadOnSelect event我如何在类型中显示所有城市,但是当值选择一个城市时,然后将整个对象放在typeaheadoneelect事件上
<input [(ngModel)]="selectedObject" [typeahead]="cityArrays" [isAnimated]="true" class="form-control" (typeaheadOnSelect)="select($event)">
According to the specification , this is what you need to do:根据规范,这是您需要做的:
<input
type="text"
placeholder="type a value from the list below"
ngxTypeahead
class="col-sm-12 form-control"
[taList]="cityArrays"
[taListItemField]="['city']"
taListItemLabel="city"
(taSelected)="handleStaticResultSelected($event)"
/>
Here is a stackblitz demo of what you are looking for. 这是您正在寻找的内容的stackblitz演示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.