我正在将ngx-chips
与autocompleteItems
一起用于标签输入,但是在添加第一个标签之后,下拉列表不再显示,并且console
中也没有错误。 / p>
HTML
<tag-input
[ngModel]="columnsToIgnore"
[ngModelOptions]="{standalone: true}"
[placeholder]="'Enter variables to ignore'"
[secondaryPlaceholder]="'Enter variables to ignore'"
[onlyFromAutocomplete]="true"
(onAdd)="addIgnoreColumn($event)"
(onRemove)="removeIgnoreColumn($event)"
theme='bootstrap'>
<tag-input-dropdown
[autocompleteItems]="selectedDataset.schema.columns"
[displayBy]="'name'"
[focusFirstElement]="true">
<ng-template let-item="item" let-index="index">
{{ item.name }} : {{ item.type }}
</ng-template>
</tag-input-dropdown>
</tag-input>
答案 0 :(得分:2)
由于您将复杂的object
用作options
,因此应使用identifyBy
,ngx-chips
将比较所选项目和提供的选项。
<tag-input
[ngModel]="columnsToIgnore"
[ngModelOptions]="{standalone: true}"
[placeholder]="'Enter variables to ignore'"
[secondaryPlaceholder]="'Enter variables to ignore'"
[onlyFromAutocomplete]="true"
(onAdd)="addIgnoreColumn($event)"
(onRemove)="removeIgnoreColumn($event)"
theme='bootstrap'>
<tag-input-dropdown
[autocompleteItems]="selectedDataset.schema.columns"
[displayBy]="'name'"
[identifyBy]="'name'" <!-- use any property of object -->
[focusFirstElement]="true">
<ng-template let-item="item" let-index="index">
{{ item.name }} : {{ item.type }}
</ng-template>
</tag-input-dropdown>
</tag-input>