Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ngx-numbers-only-directive

abfist25Mozilla Public License 2.01.0.2TypeScript support: included

An angular directive for input element that allows only numeric values

angular, input, numbers only, typescript, directive

readme

NumbersOnlyDirectiveLibrary

This project adds a new directive called NgxNumbersOnly it assures an HTML Input element will only recieve numbers.

it can be defined to allow negative numbers or disallow them as well as decimal point numbers.

This project was generated with Angular CLI version 11.2.6.

How To Install

Run npm i ngx-numbers-only-directive .

How To Use

In your appModule Import NgxNumbersOnlyDirectiveModule: import { NgxNumbersOnlyDirectiveModule }

and add it to your imports array: imports: [NgxNumbersOnlyDirectiveModule]

Add the directive to an input element. example:<input NgxNumbersOnly>

To allow Negative numbers:<input NgxNumbersOnly [allowSign]=true>

To allow decimals:<input NgxNumbersOnly [allowDecimals]=true [allowSign]=true>

Contribute

If you enjoyed this code consider donating using paypal:Donations

Thanks

The base for this directive was a StackOverflow answer by Elvis Fernandez.