@deividfortuna/input-number
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

InputNumber

An Angular directive only allows [0-9] and the feature of decimal numbers in the input box when typing, pasting or drag/dropping. This directive handles both Windows keyboard and Mac keyboard.

Installation

npm i @deividfortuna/input-number

Accept only integers numbers

  <input type="text"
        inputNumber>

Accept decimal numbers

<input type="text"
       inputNumber
       [acceptDecimalPlaces]="true"
       [decimalPlaces]="3">

API Reference

Import directive module

import { InputNumberModule } from '@deividfortuna/input-number';

Add the directive module to your angular module

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    InputNumberModule,
    AppRoutingModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Properties

acceptDecimalPlaces: boolean (default: false): Wheter the input will accept decimal or not

decimalPlaces: integer (default: 2): Number of decimal places allowed when acceptDecimalPlaces is set to true

Package Sidebar

Install

npm i @deividfortuna/input-number

Weekly Downloads

48

Version

2.0.1

License

MIT

Unpacked Size

82.6 kB

Total Files

17

Last publish

Collaborators

  • deividfortuna