Commit ccdfe9a5 authored by Sebastian's avatar Sebastian

zwischenstand.

parent f94ff581
<div class="widget-wrap widget-big">
Test 123
<ng-template #rt let-r="result" let-t="term">
<ngb-highlight [result]="r.name" [term]="t"></ngb-highlight>
</ng-template>
<label for="typeahead-basic">Search for a state:</label>
<input id="typeahead-basic" type="text" class="form-control" [(ngModel)]="model" [ngbTypeahead]="search"/>
<ng-template #rt let-r="result" let-t="term">
<img [src]="'https://upload.wikimedia.org/wikipedia/commons/thumb/' + r['flag']" class="mr-1" style="width: 16px">
<ngb-highlight [result]="r.name" [term]="t"></ngb-highlight>
</ng-template>
<label for="typeahead-template">Search for a state:</label>
<input id="typeahead-template" type="text" class="form-control" [(ngModel)]="model" [ngbTypeahead]="search" [resultTemplate]="rt"
[inputFormatter]="formatter" />
</div>
\ No newline at end of file
......@@ -8,6 +8,7 @@ import { GeoportalApiService } from '../../services/geoportal-api.service';
styleUrls: ['./autosuggest.component.css']
})
export class AutosuggestComponent implements OnInit {
public model: any;
states = {
......@@ -23,17 +24,17 @@ export class AutosuggestComponent implements OnInit {
}
ngOnInit() {
}
search = (text$: Observable<string>) =>
{
text$.pipe
(
text$.pipe(
debounceTime(200),
distinctUntilChanged(),
map(term => term.length < 2 ? []
: Object.keys(this.states).filter(v => v.toLowerCase().indexOf(term.toLowerCase()) > -1).slice(0, 10)),
map(term => term === '' ? []
: Object.keys(this.states).filter(v => v.toLowerCase().indexOf(term.toLowerCase()) > -1).slice(0, 10))
)
}
formatter = (x: {name: string}) => {
x.name
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment