>>>>UPDATE. I'm thinking that we should not use both type="number" and our own directive at the same time as the directive seems to be doing what type="number" should be doing. I'll try removing type="number" and using type="text" and see if it fixes the problem.
>>>>
>>>>UPDATE 2. By changing input type="text" from input type="number" I got rid of the error. The only problem is that this is used in many places in our application, so we would need to change all of them.
>>>
>>>If I remove the input type="number" and change it to type = "text" then the min/max attributes are ignored. Is there a way to fix our directive to still generate the errors for min /max but keep type text as type number causing this error in angularjs 1.13.3 ?
>>>
>>>I also posted it as an issue on the angularjs site.
>>>
>>>UPDATE 3. I am thinking that we need to apply our formatting directive after the input type="number" directive is applied. According to this blog post
>>>
>>>
https://coderwall.com/p/hpewqw/remember-angularjs-directives-can-have-priorities we may try using negative priority. So, this is going to be my new test - may be it will resolve the issue.
>>>
>>>UPDATE 4. So I've tried using
>>>
>>>app.directive('smNumberFormat', ['$filter', function ($filter) {
>>> return {
>>> restrict: 'A', // only activate on element attribute
>>> require: '?ngModel', // get a hold of NgModelController
>>> priority: - 3, // apply this directive after the input type="number" is applied
>>> link: function (scope, element, attrs, ngModel) {
>>>
>>>
>>>but unfortunately it didn't help with the problem and I still got the same error. Do you see a workaround for me?
>>>
>>>Thanks in advance.
>>
>>Can you post the code for your smNumber directive ?
>
>I don't think smNumber is the problem one, if I include it and input type="number", I don't get any problem. In any case, here it is:
>
>
>//source: http://docs.angularjs.org/guide/forms
>(function () {
> 'use strict';
> var ctrl = false;
> var app = angular.module('sysMgrApp');
>
> app.directive('smNumber', function () {
> return {
> link: function (scope, element, attrs, ngModel) {
> element.on('keydown', function (event) {
>
> //Set the default decimal places to 0, if accuracy is not specified
> var accuracy = parseInt(attrs.accuracy) || 0;
> if (isCombo(event)) {
> return true;
> }
>
> if (isNumericKeyCode(event.keyCode) ||
> isNavigationKeycode(event.keyCode)) {
> return true;
> }
>
> if (accuracy > 0) {
> return isDecimal(event.keyCode);
> }
>
> return false;
> });
> }
> };
>
> });
>
> function isNumericKeyCode(keyCode) {
> return (keyCode >= 48 && keyCode <= 57)
> || (keyCode >= 96 && keyCode <= 105);
> }
>
> function isDecimal(keyCode) {
> return (keyCode === 190 || keyCode === 110);
> }
>
> //function isComma(keyCode) {
> // return (keyCode === 188);
> //}
>
> function isCombo(event) {
> // c, v, x
> if (event.ctrlKey && (event.keyCode === 67 || event.keyCode === 86 || event.keyCode === 88)) { return true; }
> }
> function isNavigationKeycode(keyCode) {
> switch (keyCode) {
> case 8: //backspace
> case 35: //end
> case 36: //home
> case 37: //left
> case 38: //up
> case 39: //right
> case 40: //down
> case 45: //ins
> case 46: //del
> case 109: //subtract
> case 189: //dash
> case 9: //tab
> return true;
> default:
> return false;
> }
> }
>})();
>
Think you're right. One thing to check : Is currentSpecial.discFlat in your model a number. If it's a string I think it could cause the error - see:
https://docs.angularjs.org/api/ng/input/input%5Bnumber%5D>What is your angularjs version?
Current project is 1.3.4 - but not relevany since I haven't tried your code :-}