This package includes two Angular directives. The digitOnly directive only allows numbers in the input box when typing, pasting or drag/dropping. The mask directive checks the input pattern attribute.
npm install @uiowa/digit-onlydigitOnly directive
input type="text", not input type="number".
mask directive
pattern attribute if set.
digitOnly directive now supports disabling paste events (merges a pull request #57, fixes #56).
digitOnly directive now supports negative values (merges a pull request #49).
mask directive: support dynamic pattern attribute binding.
digitOnly directive.
digitOnly directive now dispatches an input event when paste in Firefox.
mask and digitOnly directives now also check the code attribute in KeyboardEvent.
digitOnly directive
tslib v2.0 in the dependency, which is required by TypeScript 3.9 (as of Angular 10).
digitOnly directive
digitOnly directive allows model binding to min, max, and pattern properties.
mask directive is added to this library.
##-####.
pattern attribute if set.
.. You can set it to comma when needed.
shell
npm i @uiowa/digit-only
`
Usage
`typescript
// in your Angular component
import { DigitOnlyDirective } from "@uiowa/digit-only";
@Component({
selector: "app-digit-only-demos",
imports: [DigitOnlyDirective, FormsModule],
templateUrl: "./digit-only-demos.component.html",
styleUrl: "./digit-only-demos.component.css",
})
export class DigitOnlyDemosComponent {}
`
`html
`
$3
`html
``