简体   繁体   English

如何将对象绑定到 ngx-typehead 的值?

[英]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.

相关问题 如何在 ngx-cytoscape 中获得 cy 对象的引用? - How can I get a reference of the cy object in ngx-cytoscape? 我怎样才能获得 ngx-mask 掩码值? - How can i get ngx-mask masked value? 如何绑定Angular Select中* ngFor项目的对象ID? 目前,select绑定与插值do的值相同。 - How can I bind object id from *ngFor item in Angular Select? At the moment, the select bind the same value as interpolation do. 如何根据下拉列表中的值选择来更新ngx-datatable中下一个单元格的值? - How can I update the next cell's value in ngx-datatable based on the selection of value in a dropdown? 如何将对象的属性绑定到 Angular 中的另一个对象内部? - How can i bind a property of an object inner another object in Angular? 无法绑定到“qrc-value”,因为它不是 Ionic 4.2.0 中“ngx-qrcode”的已知属性 - Can't bind to 'qrc-value' since it isn't a known property of 'ngx-qrcode' in Ionic 4.2.0 如何使用 summaryFunc/summaryTemplate 格式化 ngx-datatable 中的汇总值? - How can I format the summary value in ngx-datatable with summaryFunc/ summaryTemplate? 我可以覆盖 ngx-logger 中的消息对象吗 - Can I override message object in ngx-logger 我们如何为 angular 中的动态表单字段分配类型标题? - How can we assign typehead for dynamic form fields in angular? 如何将日期选择器中的值绑定到angular2模型? - How can I bind a value from a datepicker to an angular2 model?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM