AngularJS Example

HTML

<div ng-app="app">
  <div ng-controller="Ctrl">
      
      WANTS:  {{val | number:2}} in "input" elelent<br>
    2 decimal in input:  <input  ng-model='val' decimal-places> <br>
    2 decimal in input:  <input  type="number" step="0.01" ng-model='val' decimal-places><br>
    2 decimal in input:  <input  ng-model='val' value="{{val |number:2}}" decimal-places > <br>

  </div>
</div>

CSS

</style> <!-- Ugly Hack due to jsFiddle issue: http://goo.gl/BUfGZ --> 
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script>
<style>
​.ng-invalid { border: 1px solid red; }​

JavaScript

var app=angular.module('app',[]).controller('Ctrl',function($scope) {
  $scope.val = 12346.130123;
}).directive('decimalPlaces',function(){
    return {
        link:function(scope,ele,attrs){
            ele.bind('keypress',function(e){
                var newVal=$(this).val()+(e.charCode!==0?String.fromCharCode(e.charCode):'');
                if($(this).val().search(/(.*)\.[0-9][0-9]/)===0 && newVal.length>$(this).val().length){
                    e.preventDefault();
                }
            });
        }
    };
});