Jerryzhao-z / ng-pipes

Bunch of useful pipes for Angular2 (with no external dependencies!)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ng-pipes   NPM version Build status License

a8m/angular-filter for Angular2

This module works with Angular 2.x.

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

Installation

npm install --save ng-pipes

Get Started

Import ng-pipes to your app.module.ts

import { NgPipesModule } from 'ng-pipes';
// ...

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    // ...
    NgPipesModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Inject it to your class(could be Component, Service, etc..), or use it inside the view(template).

  • app.component.ts:

    import { Component } from '@angular/core';
    import { RepeatPipe } from 'ng-pipes';
    
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css'],
      providers: [RepeatPipe],
    })
    export class AppComponent {
      constructor(private repeater: RepeatPipe) {
        this.repeater = repeater;
      }
      title = "hello world"
      manyTitles = this.repeater.transform(this.title, 10, " ");
    }
  • app.component.html:

    <h1>
      {{ title | reverse }}
    </h1>

Project status:

Before publishing a stable version, there are several tasks to finish.
I working on that, but I will appreciate any help.

  • Add all boolean pipes
  • Finish documentation. including "Get Started" section

About

Bunch of useful pipes for Angular2 (with no external dependencies!)

License:MIT License


Languages

Language:TypeScript 99.1%Language:JavaScript 0.9%