ng2bln-count-pipe

1.1.0 • Public • Published

ng2bln-count-pipe

N|Solid

ng2bln-count-pipe is a simple to use ng2 pipe to be used to return the number of items in an array.

See the test spec file shipped along this package for further details!

Installation

ng2bln-count-pipe requires Angular.io v2.x to run.

How to use it

    ...
    import { CountPipe } from 'ng2bln-count-pipe'
    ...
    
    @NgModule ( 
      {
        imports: [
        ...
        ],
        declarations: [
          ...
          CountPipe,
          ...
        ],
      } 
    )
    export class SharedModule {
    }

The pipe takes no additional argument. It simply counts the items in an array. If it's being called upon anything else than an array, it returns NULL.

So in a Angular 2 template, simply use it this way:

<span class="badge"> {{ itemsToCount | count }} </span>

License

MIT

** Free Software **

https://www.npmjs.com/~gdrahota [keymaster.js]: https://github.com/~gdrahota [Angular2]: http://angular.io

Dependents (1)

Package Sidebar

Install

npm i ng2bln-count-pipe

Weekly Downloads

5

Version

1.1.0

License

MIT

Last publish

Collaborators

  • gdrahota