1.0.3 • Published 4 years ago
ngx-html-highlighter v1.0.3
Angular Html Highlighter
Highlight strings of text across the entire page, regardless of application, library or component boundaries.
Usage
- Install the library in your
package.jsonfor example usingnpm i --save ngx-html-highlighter. - Add the
NgxHtmlHighlighterModule.forRoot()to your module's imports section. TheforRootis necessary for the service to be available (see next item). - Inject the
HighlighterServicein your module or component. - Call
createHighlighterwith an optional options argument to create a highlighter object. The highlighter begins its work immediately. - Important: When no longer needed call
destroyon the highlighter object or alteratively pass the highlighter to the service'sdestroyHighlightermethod.
Options
export interface Options {
tagAttribute: string;
highlightClass: string;
}tagAttributeis the attribute name used to "tag" a node as having been inserted by the highlighter.highlightClassis the class added to the highlighted spans. You should add styles to this class in your global stylesheets (e.g.src/app/styles.cssin a default angular app)