@deividfortuna/input-number
v2.0.0
Published
Angular numeric input directive
Downloads
100
Maintainers
Readme
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