Filter input from value attribute

Description

The following code shows how to filter input from value attribute.

Example


<!doctype html>
<html>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js"></script>
<script type='text/javascript'>
function Ctrl($scope) {<!--   www .ja va 2s.  c om-->
  $scope.val = 1234.56789;
}
</script>
</head>
<body>
  <div ng-app="">
  <div ng-controller="Ctrl">

      WANTS:  {{val | number:2}} in "input" element<br>
    2 decimal in input:  <input  ng-model='val'> <br>
    2 decimal in input:  <input  type="number" step="0.01" ng-model='val'><br>
    2 decimal in input:  <input  ng-model='val' value="{{val |number:2}}"> <br>

  </div>
</div>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities