TrustHtmlPipe is a pipe for angular2 projects
which allows you to inject the HTML content into your templates.
Install the module into your application and save it as a dev
dependency in your
npm install trust-html-pipe --save-dev
In order to use the
TrustHtmlPipe you have to include/import
TrustHtmlModule into your application:
Or you can include the pipe directly in your components declarations list in your
Use it in your template to "inject" trusted HTML content:
<div [innerHTML]="'<strong>test html content</strong>' | trustHtml"></div>
test html content
transform(htmlString: string): any
Bypass security and trust the given value to be safe HTML.
The sanitizer will leave safe HTML intact.
WARNING: in Angular version 2.x, calling this method with untrusted user data exposes your application to XSS security risks!
htmlString - HTML string which should not be escaped.
Method returns the intact HTML string.
To build the final package run this command:
ng build trust-html
The build process will generate the packed sources into the
To publish the new version to
npm, go into the
and publish it to npm: