0.8.8 • Published 7 years ago

angular2-number-picker v0.8.8

Weekly downloads
65
License
MIT
Repository
github
Last release
7 years ago

angular2-number-picker

GitHub version NPM version

A generic number picker Angular component (v. 2.0.0+) for Twitter Bootstrap

npm.io

Requirements

UI Dependency

Installation

npm install angular2-number-picker -save

Basic usage

Import the NumberPickerComponent in your app.module and add it to the declarations array. Alternatively, you can import the NumberPickerComponent to a shared module, to make it available across all modules in your Angular application. You need to import the Angular FormsModule and ReactiveFormsModule as well.

...
import { NumberPickerComponent } from 'angular2-number-picker/components';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent,
    NumberPickerComponent
  ],
  imports: [
    FormsModule, 
    ReactiveFormsModule
    ...
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Add the angular2-number-picker directive to the page where you want to use the number picker.

<angular2-number-picker [min]="1" [max]="6" [step]="1" [precision]="1" [inputDisabled]="true" (onChange)="onNumberChanged($event)"></angular2-number-picker>

Directive Inputs and Outputs

AttributeTypeRequiredDescription
mininput NumberNoThe minimal number limit on the number picker. 0 by default
maxinput NumberNoThe maximum number limit on the number picker. 100 by default
stepinput NumberNoThe step value for the number picker. 1 by default
precisioninput NumberNoThe decimal precision for the number picker, if the step input value is a decimal value. 1 by default
inputDisabledinput BooleanNoDefines if the input input should be disabled / editable by the user. false by default
onChange(output) NumberNoThe onChange event of the component. Emits the value of the number picker, every time the user has clicked the - or + button.