The AngularJs ng-messages is a directive and
its used for displaying the messages within the templates. The messages can be
custom messages, error messages, or any kind of messages for the end user. The ngMessages
is added in AngularJs 1.3 version.
You can download to from below URLs.
The demo link , click http://embed.plnkr.co/fMG7VC140QzOkBlOV80Z/preview
The example in detail about using ng-messages
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="//code.angularjs.org/1.4.0/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-messages.js"></script>
<script>
var app =
angular.module('app',
['ngMessages']);
app.controller('MainCtrl', ["$scope", function ($scope) {
$scope.email = 'anil.singh@gmail.com';
}]);
</script>
</head>
<body ng-app="app" ng-controller="MainCtrl">
<div>
<h2> Introduction about ng-messages in
AngularJs
</h2>
</div>
<form name="form">
<div ng-class="{'has-error':
form.email.$touched && form.email.$invalid }">
Email : <input type="email" name="email" ng-model="email" required>
<div ng-messages="form.email.$error" ng-if="form.email.$touched">
<div ng-messages-include="msg.html"></div>
</div>
</div>
<div>
<button type="submit">Submit</button>
</div>
</form>
<div>
<p>
<p>form.email.$error = {{
form.email.$error | json }}</p>
</p>
</div>
</body>
</html>
The output link , click http://embed.plnkr.co/fMG7VC140QzOkBlOV80Z/preview