a8m/angular-filter for Angular 2
npm install ng-pipesThis module works with Angular 2.x.
For the AngularJS 1.x version of this module, please see angular-filter.
Installation
------------
``sh`
npm install --save ng-pipes
Get Started
------------
Import __ng-pipes__ to your app.module.ts`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: `
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: `
html`
{{ title | reverse }}
#### 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.
[npm-image]: https://img.shields.io/npm/v/ng-pipes.svg?style=flat-square
[npm-url]: https://npmjs.org/package/ng-pipes
[travis-image]: https://img.shields.io/travis/a8m/ng-pipes.svg?style=flat-square
[travis-url]: https://travis-ci.org/a8m/ng-pipes
[license-image]: http://img.shields.io/npm/l/ng-pipes.svg?style=flat-square
[license-url]: LICENSE