ngx-nl2br
v16.0.0
Published
angular pipe to transform newline to br tag
Readme
ngx-nl2br
angular pipe to transform newline to br tag
1. Description
ngx-nl2br is a pipe for angular projects to transform new line to <br />.
2. Installation
Install the module into your application and save it as a dev
dependency in your package.json file
npm install ngx-nl2br --save-dev3. Usage
In order to use the nxg-nl2br you have to include/import its module into your application:
import { NgxNl2brPipe } from "ngx-nl2br";Include it in your component's imports list of your @NgModule(...):
@NgModule({
//...
imports: [NgxNl2brModule],
//...
})Use it in your template to replace new line characters \n with
the <br /> tag:
<div [innerHTML]="'html content\nsecond line\nthird line' | nl2br"></div>
<!-- sanitize the input -->
<div [innerHTML]="'html content\nsecond line\nthird line' | nl2br : true"></div>Output:
<div><strong>html content</strong><br />second line<br />third line</div>5. Git repository
https://github.com/hkjeffchan/hkjeffchanngx
Build
Run ng build ngx-nl2br to build the project. The build artifacts will be stored in the dist/ directory.
Publishing
After building your library with ng build ngx-nl2br, go to the dist folder cd dist/ngx-nl2br and run npm publish.
Running unit tests
Run ng test ngx-nl2br to execute the unit tests via Karma.
