python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
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>
<html>
<head>
    <meta charset="utf-8">
    <title> Introduction about ng-messages in AngularJs</title>
    <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 = '[email protected]';
        }]);
    </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>



ANIL SINGH

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions