angular pipe to transform newline to br tag
angular pipe to transform newline to br tag
- ngx-nl2br
- 1. Description
- 2. Installation
- 3. Usage
- 5. Git repository
- Build
- Publishing
- Running unit tests
ngx-nl2br is a pipe for angular projects to transform new line to .
Install the module into your application and save it as a dev
dependency in your package.json file
```
npm install ngx-nl2br --save-dev
In order to use the nxg-nl2br you have to include/import its module into your application:
`typescript`
import { NgxNl2brPipe } from "ngx-nl2br";
Include it in your component's imports list of your @NgModule(...):
`typescript`
@NgModule({
//...
imports: [NgxNl2brModule],
//...
})
Use it in your template to replace new line characters \n with
the tag:
`
Output:
`html
html content
second line
third line
`$3
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.