thatThe code below works for me well, but if I put inonly when the input type = "number" does not work meis text, and I needit doesn't work when the input is type is number.
<div ng-app="myApp" ng-controller="myCtrl as model"> <input type="text" ng-model="cero" ng-decimal > </div> angular .module("myApp",[]) .controller('myCtrl', function($scope){ var model=this; }) .directive('ngDecimal', function ($parse) { var linkFunction =function(scope, element, attrs){ element.bind("keypress", function(event) { if(event.which === 13) { scope.$apply(function(){ scope.$eval(attrs.format, {'event': event}); if(scope.cero===undefined || scope.cero===''){ scope.cero="0.", event.preventDefault(); }else{ } }); } }); }; return{ restrict : 'A', scope:{ cero: '=ngModel' }, link: linkFunction } }); What I need help with is changing the type to number and still making the codepen:code work. The code is also on http://codepen.io/fernandooj/pen/EgmQmJ?editors=1011CodePen.