JSPM

angular2-truncate

0.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q37250F
  • License MIT

Package Exports

  • angular2-truncate

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (angular2-truncate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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:

import { TruncatePipe } from 'angular2-truncate';
...
@NgModule({
  declarations: [
    TruncatePipe
  ]
})

Use the pipe directly in your HTML files/templates:

<span>{{ name }}</span>
<!-- angular2-truncate -->

<span>{{ name | truncate }}</span>
<!-- angular2-t... -->

<span>{{ name | truncate : 6 }}</span>
<!-- angula... -->

<span>{{ name | truncate : 6 : '___' }}</span>
<!-- angula___ -->

<span>{{ name | truncate : 6 : '___' : 'left' }}</span>
<!-- ___uncate -->

<span>{{ name | truncate : 6 : null : 'middle' }}</span>
<!-- 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