I want to use the component: codex to show & select & possibly create new items.
My items are not devices (IIdentified
) but a list of client name: clients : string []
;
When I use the template:
<c8y-typeahead container="body" name="selectedClient" [placeholder]="'Search for devices...'"
(onSearch)="setPipe($event)" [allowFreeEntries]="true" [(ngModel)]="selectedClient">
<c8y-li class="p-l-8 p-r-8 c8y-list__item--link"
*c8yFor="let client of clients; notFound: notFoundTemplate; pipe: filterPipe"
(click)="selectedClient = client" [active]="selectedClient === client">
<c8y-highlight [text]="client" [pattern]="pattern"></c8y-highlight>
</c8y-li>
<ng-template #notFoundTemplate>
<c8y-li class="bg-level-2 p-8 sticky-bottom" *ngIf="pattern.length > 0">
<span translate>No exact match found.</span>
<button class="btn btn-default btn-sm m-l-8" title="Add new client" type="button" translate>
Add new client
</button>
</c8y-li>
</ng-template>
</c8y-typeahead>
I get an error:
Type 'string[]' is not assignable to type 'IResultList<IIdentified> | Observable<IResultList<IIdentified>>'.
Type 'string[]' is missing the following properties from type 'Observable<IResultList<IIdentified>>': source, operator, lift, subscribe, and 2 more.
What do I have to modify the template:
- to use string as items
- offer to create a new client if it does not exist
Regards Christof