Question: I'm stumbling upon weird case while using angularJs and input type="number". Basically, if I have input with type number and initial value falls outside range defined by min and max, my initial value is simply destroyed.

I've made fiddle to illustrate the problem - <http://jsfiddle.net/PK3QH/2/>

HTML:

```
<div ng-controller="MyCtrl">
    <input ng-model="bindData.SomeAmount" type="number" required="required" />
    <br />
    <input ng-model="bindData.SomeAmount" type="number" required="required" 
        min="2" max="10" />
</div>

```

Javascript:

```
var myApp = angular.module('myApp',[]);

function MyCtrl($scope) {
    $scope.bindData = {
        SomeAmount: 1
    };
}

```

As you can see first textbox works without any problems, but the second one simply doesn't display the value. I definitely need value to be preserved while also being validated as number in certain range - so is there any way our this?

Answer: 
I agree this is a bug.

This happens because the formatters are applied first before validators. 
The formatter in the case of 'number' 

```
  if (attr.min) {
    var minValidator = function(value) {
      var min = parseFloat(attr.min);
      return validate(ctrl, 'min', ctrl.$isEmpty(value) || value >= min, value);
    };

    ctrl.$parsers.push(minValidator);
    **ctrl.$formatters.push(minValidator);**
  }

```

all the $formatters are run first before the validators are run initially...checkout NgModelController.

I wonder if the "first" time when $dirty != true if they applied the formaters based on validity i.e. let the formatters yield if the validation results to false.

In the case of minNumber the formatter should be only a number. Why do we need a formatter for minNumber ?

Raised it <https://github.com/angular/angular.js/issues/8264>

Until the Angular team fixes this short term solution would be to use your own directive instead of min.
IMHO, this is a bug.

If you remove ng-model attribute, you see the initial value.

If this is NOT a bug, when we type invalid value such as 40, we must not see the entered text as it happend as when initialized. See, it's not consistent.

It only happens for the first time when input directive is initialized.

IMO, Even though, the model value is not value, it should preserve the original value by not setting to blank.

Sorry for not providing solution.