File

projects/ngui-common/src/lib/ngui-utils/src/ngui-highlight.pipe.ts

Metadata

Methods

transform
transform(text: string, search: string)
Parameters :
Name Type Optional
text string No
search string No
Returns : string
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({ name: 'nguiHighlight' })
export class NguiHighlightPipe implements PipeTransform {
  transform(text: string, search: string): string {
    let ret = text;
    if (search) {
      const re  = new RegExp(search, 'ig');
      ret = text.replace(re, match => `<span class="ngui-highlight">${match}</span>`);
    }

    return ret;
  }
}

results matching ""

    No results matching ""