I\'m having problems binding a number value using AngularJS.
I\'ve put a simplified example on JSFiddle: http://jsfiddle.net/treerock/ZvdXp/
You can also fix this with a directive. I created a directive to force input bound to numeric fields to be numeric.
Html:
myApp.directive('numericbinding', function () {
return {
restrict: 'A',
require: 'ngModel',
scope: {
model: '=ngModel',
},
link: function (scope, element, attrs, ngModelCtrl) {
if (scope.model && typeof scope.model == 'string') {
scope.model = parseInt(scope.model);
}
}
};
});
You can add it to your numeric field like this:
full example: http://jsfiddle.net/tdjager/cMYQ3/1/