支持对象和自定义模板的Angular2/4 typeahead?

支持对象和自定义模板的Angular2/4 typeahead?,angular,typeahead,Angular,Typeahead,我有以下资料: [{'title':'Book Title', 'author':'author, 'type':'book'},{'title':'Btitle', 'author':'Bauthor', 'type': 'book'},{'title':'Movie Title', 'author': 'Director', 'type': 'movie'}] 我想有一个输入字段(文本),我可以用来键入和显示一个typeahead。我试过: ng2 completer-支持对象,但不支持预

我有以下资料:

[{'title':'Book Title', 'author':'author, 'type':'book'},{'title':'Btitle', 'author':'Bauthor', 'type': 'book'},{'title':'Movie Title', 'author': 'Director', 'type': 'movie'}]
我想有一个输入字段(文本),我可以用来键入和显示一个typeahead。我试过:

ng2 completer-支持对象,但不支持预览内容中的自定义模板

ngx引导-不支持对象,但支持自定义模板


我所希望的就是能够在我的输入字段中具有一个typeahead功能,该功能带有自定义模板,根据数据类型使用自定义值。我该怎么做?或者angular2/4有什么东西支持这一点吗?

您可以尝试使用PRIME NG,它支持对象和模板,与
ngModel
和反应式表单一起工作

以下是吴总理的官方例子:

<p-autoComplete [(ngModel)]="brand" 
                [suggestions]="filteredBrands" 
                (completeMethod)="filterBrands($event)">
  <ng-template let-brand pTemplate="item">
    <div class="ui-helper-clearfix" style="border-bottom:1px solid #D5D5D5">
      <img src="assets/showcase/images/demo/car/{{brand}}.png" style="width:32px;display:inline-block;margin:5px 0 2px 5px"/>
      <div style="font-size:18px;float:right;margin:10px 10px 0 0">{{brand}}</div>
    </div>
  </ng-template>
</p-autoComplete>

{{brand}}