API Reference / @dasch-ng/utils / src / HighlightPipe
Class: HighlightPipe
Defined in: libs/ng/utils/src/lib/highlight.pipe.ts:23
Splits text into matching and non-matching segments for a search term, case-insensitively. The template renders the matches, so no HTML is built from strings and nothing needs sanitizing:
html
@for (part of label | highlight: query; track $index) {
@if (part.match) {<mark>{{ part.text }}</mark>} @else {{{ part.text }}}
}The term is matched literally; regex characters in it have no special meaning.
Implements
PipeTransform
Constructors
Constructor
new HighlightPipe():
HighlightPipe
Returns
HighlightPipe
Methods
transform()
transform(
text,term):HighlightSegment[]
Defined in: libs/ng/utils/src/lib/highlight.pipe.ts:24
Parameters
text
string | null | undefined
term
string | null | undefined
Returns
Implementation of
PipeTransform.transform