angular2-truncate
A simple angular2 pipe which truncate strings.
Installation
To install this library, run:
$ npm install angular2-truncate --save
Usage
Add the declaration in your app.module.ts
file:
;...
Use the pipe directly in your HTML files/templates:
{{ name }}<!-- angular2-truncate --> {{ name | truncate }}<!-- angular2-t... --> {{ name | truncate : 6 }}<!-- angula... --> {{ name | truncate : 6 : '___' }}<!-- angula___ --> {{ name | truncate : 6 : '___' : 'left' }}<!-- ___uncate --> {{ name | truncate : 6 : null : 'middle' }}<!-- ang...ate -->
Parameters
Parameter name | Type | Default value | Comment |
---|---|---|---|
limit | number | 10 | |
trail | string | '...' | |
position | string | 'right' | Allowed values are: 'left' , 'middle' , 'right' |
Development
To generate all *.js
, *.js.map
and *.d.ts
files:
$ npm run tsc
To lint all *.ts
files:
$ npm run lint
License
MIT © Sylvain RAGOT