21 lines
400 B
TypeScript
21 lines
400 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) {
|
||
|
return this.search.bind(ref, list);
|
||
|
}
|
||
|
|
||
|
search(arr, str) {
|
||
|
const qs = new QuickScore(arr);
|
||
|
return of(str === '' ? [] : qs.search(str).map(e => e.item));
|
||
|
}
|
||
|
}
|