Bind form error message

Description

The following code shows how to Bind form error message.

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  w  w . ja  va  2 s.co  m-->
<body ng-app="myApp">
  <div ng-controller="MyCtrl">
    <form name="form">
        <input type="number" name="name" ng-model="id" required>
        <p>form.name.$error: {{form.name.$error}}</p>
    </form>
</div>
<script type='text/javascript'>

var myApp = angular.module('myApp',[]);

function MyCtrl($scope) {
    $scope.id = null;
}
</script>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities