Reputation: 1337
I have this case where there are two inputs that I want to bind on the same object , they represent start and end of a range
<input type="number" ng-model="price.values[0]"> - <input type ="number" ng-model="price.values[1]">
the issue is that when I enter one value and leave the other empty this is what I get inside the object :
values :
0: 111
1: NaN
I am wondering about the NaN part what exactly is going on and how can I avoid binding to NaN when its empty
Upvotes: 1
Views: 58
Reputation: 3200
You can simply preset values to null
or undefined
in your controller:
$scope.price = {
values: [ null, null ]
}
Here you have working example: http://jsfiddle.net/gf5excbt/
Upvotes: 1