$viewValue and $modelValue default to Number.NaN
-- JavaScript Definition for Not - a - Number.
check Github and you find that
var NgModelController = ['$scope', '$exceptionHandler', '$attrs',
'$element', '$parse',
'$animate', '$timeout',
function($scope, $exceptionHandler, $attr, $element, $parse,
$animate, $timeout)
{
this.$viewValue = Number.NaN;
this.$modelValue = Number.NaN;
Why is this convienient? Because AngularJS tries to avoid having cases like null
and undefined
. View Values and Model Values are bound and defined by "scope". That's the point of the $scope service -- to manage the modelValue and viewValue.
Until an AngularJS service accesses them, they are defaulted to number.NaN