2
Fork 0
definma-ui/src/app/services/autocomplete.service.ts

21 lines
416 B
TypeScript

import { Injectable } from '@angular/core';
import {QuickScore} from 'quick-score';
import {of} from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class AutocompleteService {
constructor() { }
bind(ref, list: string[]) {
return this.search.bind(ref, list);
}
search(arr: string[], str: string) {
const qs = new QuickScore(arr);
return of(str === '' ? [] : qs.search(str).map(e => e.item));
}
}