typescript 搜索5.ts
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了typescript 搜索5.ts相关的知识,希望对你有一定的参考价值。
@Directive({
selector: '[searchableHighlight]'
})
export class SearchableHighlightDirective {
constructor(@Optional() private container: SearchableContainerComponent,
@Optional() private searchable: SearchableDirective,
private sanitizer: DomSanitizer,
private host: ElementRef) {
if (!searchable) {
throw new Error(`Missing [searchable] directive`);
}
}
ngOnInit() {
this.container.register(this, { highlight: true });
}
ngOnDestroy() {
this.container.unregister(this, { highlight: true });
}
get token() {
return this.searchable.token;
}
highlight(token: string, searchTerm: string) {
this.host.nativeElement.innerHTML = this.sanitizer.sanitize(SecurityContext.HTML, this.resolve(token, searchTerm));
}
resolve(token: string, searchTerm: string) {
...removed for brevity, you can see it in the full demo
}
}
以上是关于typescript 搜索5.ts的主要内容,如果未能解决你的问题,请参考以下文章
typescript 5.ts
typescript 阿比 - 5.ts
typescript ML-5.ts
typescript SD-5.ts
typescript 1.8-5.ts
typescript 键盘5.ts