New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ngx-number-spin

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-number-spin

An Angular number spin component

latest
Source
npmnpm
Version
0.0.4
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

ngx-number-spin

This is an angular number spinner component.

Installation

To install this library (component), run:

$ npm i ngx-number-spin --save

Usage

add NumberPickerModule to AppModule

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

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

// Import this library
import { NgxNumberSpinModule } from 'ngx-number-spin';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    
    // Specify this library as an import
    NgxNumberSpinModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

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

Standalone Examples

export class AppComponent {
    change(value: number): void {
        console.log(value);
    }
}
With validation 'MIN' value (min=1)
<ngx-number-spin
    [value]="4"
    (change)="change($event)" 
    [min]="1">
</ngx-number-spin>
With validation 'MAX' value (min=9)
<ngx-number-spin 
    [value]="4"
    (change)="change($event)" 
    [max]="9">
</ngx-number-spin>
With validation 'MIN' and 'MAX' value (min=1, max=9)
<ngx-number-spin 
    [value]="4"
    (change)="change($event)"
    [min]="1"
    [max]="9">
</ngx-number-spin>
With 'STEP' (step=5)
<ngx-number-spin
    (change)="change($event)" 
    [step]="5">
</ngx-number-spin>

Form Example

import { FormBuilder, FormGroup, FormControl } from '@angular/forms';

export class AppComponent {
    form: FormGroup;
    
    constructor(private fb: FormBuilder) {
        this.form = this.fb.group({
            price: 11
        });
    }
       
    submit() {
        alert(JSON.stringify(this.form.value));
    }
}
<form [formGroup]="form" (submit)="submit()">

    <ngx-number-spin formControlName="price" [min]="1" [max]="9"></ngx-number-spin>
    
    <button type="submit">submit</button>
</form>

Component Inputs and Outputs

AttributeTypeRequiredDefaultDescription
value[input] numberNo0initial value for the spinner
min[input] numberNonulllimit the minimal number
max[input] numberNonulllimit the maximum number
spin[input] numberNo1increment or decrement by current number
(change)(output) numberno-emits the value of the current number, every time the user clicks the - or + button

ngx-number-spin example image

Keywords

ng

FAQs

Package last updated on 20 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts