A collection of pipes for Angular apps.
Use npm to install @nglrx/pipes.
npm i @nglrx/pipes
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 { }
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.