import { Pipe, PipeTransform } from '@angular/core'; import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; @Pipe({ name: 'NaHighlight' }) export class NaHighlightPipe implements PipeTransform { constructor(private domSanitizer: DomSanitizer) {} transform(value: any, val: string, style: string = 'color: red;'): SafeHtml { const newstr = value.replace(new RegExp(val, 'g'), `${val}` ); return this.domSanitizer.bypassSecurityTrustHtml(newstr); } }