# number-input-formatter

> This Angular Module (formControl) allows you to enter digits or floats with length limits and dislpay is formatted but return is a number

Latest version **1.2.4** (published 2022-02-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install number-input-formatter
pnpm add number-input-formatter
yarn add number-input-formatter
bun add number-input-formatter
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.4 |
| Published | 2022-02-18 |
| First published | 2022-01-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 87.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mike Boni |
| Maintainers | wavecoders |
| Keywords | angular, number, float, min length, max length, format, formatter, min value, max value, currency, input, digits, float, pattern |

## Links

- npm: https://www.npmjs.com/package/number-input-formatter
- Homepage: https://wavecoders.ca
- npm.io page: https://npm.io/package/number-input-formatter

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.3.0

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.2.4 (latest) — 2022-02-18
- 1.2.3 — 2022-01-31
- 1.2.1 — 2022-01-28
- 1.1.9 — 2022-01-27
- 1.1.8 — 2022-01-27
- 1.0.2 — 2022-01-26
- 1.0.1 — 2022-01-26

## README

# Number Input Formatter

This Angular Material component (Module) allows you to have an input field that adresses formatting and returns just the value without the formatting. 

The input field supports commas to separte the value and 2 decimals for floats. You can specify if you only require the integer and not decimal value.

## Installation
```
npm install number-input-formatter
```

## Scaffolding

Import the module into your project under imports

```
imports: [
  BrowserModule,
  AppRoutingModule,
  NumberInputFormatterModule
]
```

## Use

First create a formControl defining the input

```
form = this.fb.group({
  number_1: [null],
  number_2:[null]
})
```

In your component, use the following tag

```
<div style="margin: 24px;" [formGroup]="selection">
  <wav-numeric-input-formatter
    [placeholder]="'100.00'"
    [label]="'Total Amount'"
    [prefix]="'$'"
    [suffix]="'.00'"
    [float]="false"
    formControlName="number_1"
  ></wav-numeric-input-formatter>
</div>
```

if you do not want to use it as a formControl then the implementation looks like this

```
<wav-numeric-input-formatter
[placeholder]="'100.00'"
[label]="'Total Amount'"
[float]="true"
></wav-numeric-input-formatter>
```

## Inputs

The following Inputs are available

| Input | Type | Defaut | Description |
| ----- | ---- | ------ | ----------- |
| label             | STRING    | NULL    | Label for input |
| placeholder       | STRING    | NULL    | Placehold for input |
| appearence        | STRING    | NULL    | field style |
| float             | BOOLEAN   | FALSE   | Allow for 2 decimals in format |
| prefix            | STRING    | NULL    | prefix string to field |
| suffix            | STRING    | NULL    | suffix string to field |
| maxLen            | NUMBER    | NULL    | limit text entry length |
| maxValue          | NUMBER    | NULL    | limit max value |
| maxValue          | NUMBER    | NULL    | limit min value |
| required          | BOOLEAN   | FASLE   | field is required |

## Sample Implementation

```
<wav-numeric-input-formatter
  [placeholder]="'100.00'"
  [label]="'Total Amount'"
  [float]="true"
  formControlName="number_2"
></wav-numeric-input-formatter>

```

## Input return

You will note that the control will return the number - no formatting is included 

Below is a sample of the implementation

```
form = this.fb.group({
  number_1: [null],
  number_2:[null]
})
```

```
ngOnInit() {

  this.form.patchValue({ number_1: 12221.1, number_2: '1234'})
  this.form.valueChanges.subscribe(data => console.log(data))

}
```

HTML setup for component with inputs and outputs

```
<div [formGroup]="form">
  <app-numeric-input-formatter
    fxFlex="30"
    [placeholder]="'100.00'"
    [label]="'Total Amount'"
    [float]="true"
    [required]="true"
    [maxLen]="10"
    [appearence]="'outline'"
    formControlName="info"
  ></app-numeric-input-formatter>

    <wav-numeric-input-formatter
    [placeholder]="'100.00'"
    [label]="'Total Amount'"
    [float]="true"
    formControlName="number_2"
  ></wav-numeric-input-formatter>
</div>
```

---
_Source: https://npm.io/package/number-input-formatter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
