diff --git a/CHANGELOG.md b/CHANGELOG.md index e04684b..d10bd99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ + +## [v1.0.4](https://github.com/changLiuUNSW/angular-numeric-input/compare/1.0.3...1.0.4) (2020-12-10) + +### Added + +- can setting decimal precision (html tag attr: decimal-precision) +- modify regexp controller decimal precision number to limited (to limit the decimal-precision number) + ## [v1.0.4](https://github.com/changLiuUNSW/angular-numeric-input/compare/1.0.3...1.0.4) (2017-05-28) diff --git a/dist/angular-numeric-input.js b/dist/angular-numeric-input.js index 8684a16..3ff7315 100644 --- a/dist/angular-numeric-input.js +++ b/dist/angular-numeric-input.js @@ -25,8 +25,18 @@ if (attrs.allowDecimal) { positiveInteger = false; - precision = 2; + /* + 2020-12-10 Rong add can setting decimal precision + and + modify regexp controller decimal limit + */ + if(attrs.decimalPrecision){ + precision = attrs.decimalPrecision; + }else{ + precision = 2; + } min = 0; + NUMBER_REGEXP = new RegExp("^\\s*[-+]?(\\d+|\\d*\\.\\d{0," + precision + "})\\s*$") } if (attrs.minNotEqual) { @@ -105,6 +115,7 @@ return value; } + var copyValue ngModelCtrl.$parsers.push(function(input) { //check undefined and NaN //http://adripofjavascript.com/blog/drips/the-problem-with-testing-for-nan-in-javascript.html @@ -193,4 +204,4 @@ } }; }]); -})(); \ No newline at end of file +})();