Bind number input to number type model

Description

The following code shows how to bind number input to number type model.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--from   w  ww  . j  a v a  2  s .  c  om-->
<body>
<div ng-app>
    <div ng-controller="MyCtrl">
        Number field: 
        <input type="number" step="any" ng-model="Number" required />
        <br />
        Result: {{Number}}
    </div>
</div>
<script type='text/javascript'>
function MyCtrl($scope) {
    $scope.Number = 10.05;
}
</script>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities