ngx-number-validation
Validation of numbers to Angular. Includes pipes, directives, reactive forms among others.
Install with:
$ npm install ngx-number-validation
Implement in your project
You must import the NgxNumberValidationModule
module to your main module, next to theforRoot
method.
; ;
Module options
decimalSeparator
, thousandSeparator
and decimalCount
.
Directives
Example
<!-- number between -10 and 10 (with 2 decimals) -->
numberMinLimit
Limit the possible minimum number for an input
.
numberMaxLimit
Limit the possible maximum number for an input
.
numberDecimals
Limit the possible decimals count for an input
.
Pipes
Format numbers
The options available for the pipe are the same as for the module, and if any value is not setted then the default options of the module will be used.
Pipe: {{ 12000 | numberFormat: { thousandSeparator: ',', decimalSeparator: '.', decimalCount: 2 } }}
It is also possible to pass only the number of decimals and that the other options are established according to the module:
Pipe: {{ 12000 | numberFormat: 2 }}
Services
Only one service is occupied and you can access the main instance of the system.
Transform local number to a native number
Sum + 4: {{ sum() }}
; ;