angular - ng-bootstrap Typeahead selected object -
i have https://ng-bootstrap.github.io/#/components/typeahead/api component folowing declaration:
<ng-template #rt let-r="result" let-t="term"> <span class="device"> <span class="grayout">{{r?.manufacturer.name}}</span> {{ r?.modelname}}, <span class="grayout"> {{ r?.year}}, {{r?.operatingsystemversion.operatingsystem.name}} {{r?.operatingsystemversion.name}}, {{ r?.note}} </span> </span> <span class="devicestats"> <span class="grayout">{{r?.blockedcount}}x blocked</span> </span> </ng-template> <input id="typeahead-template" type="text" class="form-control" [(ngmodel)]="model" [ngbtypeahead]="search" [resulttemplate]="rt" [inputformatter]="formatter" placeholder="search model, manufacturer, operating system, operation system version, serial number, code etc." />
and component code:
export class homecomponent implements oninit { account: account; modalref: ngbmodalref; userreservations: reservation[]; model: device; searching = false; searchfailed = false; search = (text$: observable<string>) => _do.call( switchmap.call( _do.call( distinctuntilchanged.call( debouncetime.call(text$, 300)), () => this.searching = true), term => _catch.call( _do.call(this.deviceservice.search(term), () => this.searchfailed = false), () => { this.searchfailed = true; return of.call([]); } ) ), () => this.searching = false);
so json response contains device[]. list suggested options works correctly because template used , there can access properties when select option in input there [object object] value. is possible populate e.g. tostring() method device object?
thank you.
there inputformatter that.
Comments
Post a Comment