a8m / ng-pipes

Bunch of useful pipes for Angular2 (with no external dependencies!)
https://a8m.github.io/ng-pipes/
MIT License
117 stars 24 forks source link
angular angular-filters filter ng-pipes pipes

ng-pipes   NPM version Build status License Join the chat at https://gitter.im/ng-pipes/Lobby

a8m/angular-filter for Angular (2+)

For the AngularJS version of this module, please see angular-filter.

Installation

npm install --save ng-pipes

or

yarn add ng-pipes

Get Started

There are 3 ways of adding ng-pipes to your project:

  1. Import all pipes
  2. Import pipes by module
  3. Declare specific pipes

Import all pipes

import { NgPipesModule } from 'ng-pipes';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    NgPipesModule
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
<h1>
  {{ title | reverse }}
</h1>

Import pipes by module

import {BooleanPipesModule, CollectionPipesModule, MathPipesModule, ObjectPipesModule, StringPipesModule} from 'ng-pipes';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BooleanPipesModule,     // imports all pipes of the boolean module
    CollectionPipesModule,  // imports all pipes of the collection module
    MathPipesModule,        // imports all pipes of the math module
    ObjectPipesModule,      // imports all pipes of the object module
    StringPipesModule       // imports all pipes of the string module
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
<h1>
  {{ title | reverse }}
</h1>

Declare specific pipes

import { ReversePipe, CeilPipe, ... } from 'ng-pipes';
// ...

@NgModule({
  declarations: [
    AppComponent, ReversePipe, CeilPipe, ...
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
<h1>
  {{ title | reverse }}
</h1>

Contributing

Submitting a Pull Request (PR)

  1. Clone the project via:

    $ git clone https://github.com/a8m/ng-pipes.git
  2. Make your changes in a new git branch:

    $ git checkout -b my-cool-branch master
  3. Add your changes, including appropriate test cases.

  4. Push your branch to Github.

  5. Create a PR to master.