I\'m just starting to play around with AngularJS and trying to understand the binding technique. For starters, I tried to make a simple conversion calculator (dozens to pieces,
I think this solution is more generic.
myApp.directive('input', function() { return { restrict: 'E', require: '?ngModel', link: function(scope, element, attrs, ngModel) { if ('type' in attrs && attrs.type.toLowerCase() === 'range') { ngModel.$parsers.push(parseFloat); } } };
});
full explanation