Introduction about ng-messages in AngularJs

Introduction about ng-messages in AngularJs

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 example in detail about using ng-messages

<!DOCTYPE html>
    <meta charset="utf-8">
    <title> Introduction about ng-messages in AngularJs</title>
    <script src="//"></script>
    <script src="//"></script>
        var app = angular.module('app', ['ngMessages']);
        app.controller('MainCtrl', ["$scope", function ($scope) {
            $ = '[email protected]';
<body ng-app="app" ng-controller="MainCtrl">
        <h2> Introduction about ng-messages in AngularJs </h2>
    <form name="form">
        <div ng-class="{'has-error':$touched &&$invalid }">
            Email : <input type="email" name="email" ng-model="email" required>
            <div ng-messages="$error" ng-if="$touched">
                <div ng-messages-include="msg.html"></div>
            <button type="submit">Submit</button>
            <p>$error = {{$error | json }}</p>


Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - and
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like Powered by Blogger.
ASK Questions