Skip to content

nglrx/pipes

Repository files navigation

npm GitHub last commit Libraries.io dependency status for latest release, scoped npm package Quality Gate Status GitHub

@nglrx/pipes

A collection of pipes for Angular apps.

Installation

Use npm to install @nglrx/pipes.

npm i @nglrx/pipes

Import

Import module NglrxPipesModule to your module for using all pipes.

import { NglrxPipesModule } from '@nglrx/pipes';

@NgModule({
  //...
  imports: [
    NglrxPipesModule
  ]
})
export class YourModule { }

Alternatively, you can use pipes from specific module(s)

import { NglrxGenericPipesModule, NglrxStringPipesModule } from '@nglrx/pipes';

@NgModule({
  //...
  imports: [
    NglrxGenericPipesModule,
    NglrxStringPipesModule
  ]
})
export class YourModule { }

Usage

Pipes can be used in your component's template

{{ 'This-is-a-string' | length }} <!-- Returns 16 -->

They can also be chained

{{ '  Another-string  ' | trim | length }} <!-- Returns 14 -->

Or they can be used within components or services by calling the transform method

import { LengthPipe } from '@nglrx/pipes';

@Component({
  providers: [ LengthPipe ]
})
export class YourComponent {
  
  constructor(private lengthPipe: LengthPipe) {
    this.lengthPipe.transform('Yet-another-string'); // Returns 18
  }
}

For more information on pipes, refer to Angular - pipes documentation.