21 lines
428 B
TypeScript
21 lines
428 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));
|
|
}
|
|
}
|