0.3.2 • Published 6 years ago

ngx-counter v0.3.2

Weekly downloads
36
License
MIT
Repository
github
Last release
6 years ago

ngx-counter

Customizable counter component for Angular 2+

npm version license

Installation

NPM

To install this library, run:

$ npm install ngx-counter --save

Usage

And then from your Angular AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import the library
import { CounterModule } from 'ngx-counter';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,

    // Specify the library as an import
    CounterModule.forRoot()
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Once the library is imported, you can use its component in your Angular application:

<!-- You can now use the library component in app.component.html -->
<h1>
  {{title}}
</h1>
<ngx-counter></ngx-counter>

Model binding

<ngx-counter [(ngModel)]="myCountValue"></ngx-counter>

Parameters

ParameterTypeDefaultDescription
countValuenumber0Count value that will be incremented
limitnumbercountValue + 10Limit where counting will stop
speednumber1000Speed of the counter in milli-seconds
changeeventnoopThe callback function for each count change
sizestringmediumSize of the counter display 'small', 'medium', 'big', 'large', 'xl'
fontstringmonospaceFont family to use
themestringblueColor theme 'blue', 'red', 'green', 'gray'
colorstringblueMain color for the number and the border (if no theme specified)
bgcolorstring#d6f0f9Background color to use (if no theme specified)

Examples

<ngx-counter [(ngModel)]="counterStart" [limit]=10 size="small" theme="red"></ngx-counter>
<ngx-counter [countValue]=1 [limit]=10 font="cursive" theme="green"></ngx-counter>
<ngx-counter [countValue]=0 [speed]=1000 size="big" (change)="counterChanged($event)"></ngx-counter>
<ngx-counter [countValue]=-1 [limit]=counterFinish size="large" font="Arial" theme="gray"></ngx-counter>
<ngx-counter countValue=-2 limit=10 size="xl" color="gold" bgcolor="#F5F5DC"></ngx-counter>

ngx-counter

License

MIT © Kris Nyunt

0.3.2

6 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago