1.1.9 • Published 6 years ago

ng-number-picker v1.1.9

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

ng-number-picker

Build Status License NPM Release NPM Monthly Downloads

A number picker input for angular 2+ & bootstrap 4+. It supports the mousewheel and the up/down keys and increase/decrease input value continuously by long tap the up/down buttons.

Getting Started

These instructions will get you an copy of the ng-number-picker module up and running on your local machine for development purposes. See Options & Events for more details.

Try it

Try it on: Plunker or stackblitz

Requirements

  1. Angular2.x
  2. Bootstrap4.x

Installation

Run npm install --save ng-number-picker from the command line, then import the NgNumberPickerModule into your appModule :

import {NumberPickerModule} from 'ng-number-picker';

@NgModule({
  imports: [
    NumberPickerModule
  ],
  ...
  ...
})

Run npm install --save bootstrap from the command line to install Bootstrap4.x, then include the style into your angular.json file (or angular-cli.json for angular version < 6.0) similar to the following:

"styles": [
  "node_modules/bootstrap/dist/css/bootstrap.min.css"
],
...

Usage

Add the following line into your html template :

<ng-number-picker [(value)]="value"></ng-number-picker>

Options

The following options are the available component inputs :

INPUTTYPEDEFAULTDISCRIPTION
minnumber0Minimum value
maxnumber100Maximum value
stepnumber1The step value for up/down change
valuenumbernullInitial input value
pickStartAfternumber500The time in milliseconds before start picking values. Used when holding click on up/down buttons.
pickTimernumber100The time in milliseconds for step auto incrementation/decrementation. Used when holding click on up/down buttons.
prefixstringnullText value before the input
postfixstringnullText value after the input
placeholderstringnullInput placeholder
sizesizeTypemdThe input size. Please take a look at the available size types.
buttonsOrientationbuttonsOrientationTypehThe orientation strategy for up/down buttons. Please take a look at the available orientation types.
customClassCustomClasses{}Set custom css classes around the component. Please take a look at the available custom classes options.
mouseWheelbooleanfalseEnable/disable change input value with mouseWheel
arrowKeysbooleantrueEnable/disable change input value with up/down arrow keys
inputReadOnlybooleanfalseReadonly input
showUpButtonbooleantrueShow/hide upward button
showDownButtonbooleantrueShow/hide downword button

Default options

You can change the default options values exist in the NumberPickerService by creating a CustomNumberPickerService similar to the following:

import {NumberPickerModule, NumberPickerService} from 'dist/number-picker';

export class CustomNumberPickerService {
  min = 10;
  max = 50;
  step = 5;
  precision = 1;
  pickStartAfter = 100;
  pickTimer = 100;
  value = 15;
}

@NgModule({
  imports: [
    NumberPickerModule
  ],
  providers: [{provide: NumberPickerService, useClass: CustomNumberPickerService}],
  ...
  ...
  ...
})

Events

Triggered events

The following events are triggered on the input and can be listened on.

EVENTDISCRIPTION
valueChangeTriggered when the value is changed with one of the +/- buttons
minReachedTriggered when the input value hit the limit set by the min option
maxReachedTriggered when the input value hit the limit set by the max option
pickStartedTriggered when start picking numbers upwards or downwards
pickStopedTriggered when stop picking numbers upwards or downwards
pickUpStartedTriggered when start picking numbers upwards
pickUpStopedTriggered when stop picking numbers upwards
pickDownStartedTriggered when start picking numbers downwards
pickDownStopedTriggered when stop picking numbers downwards
1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago