First check if your module has ngMessages, in the second ng message you need a form (in your case with the name "Form" in my myForm fragment), and the last time you should check if your ng model has a controller or something, where do you have the data. You also need a valid form for md-is-error.
Sorry for my knowledge of English, I canβt explain your mistakes correctly, but you can check my fragment.
<html> <head> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular-messages.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-sanitize.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script> <style type="text/css"> .validation-messages { font-size: 11px; color: darkred; margin: 10px 0 0 25px; } </style> </head> <body ng-app="testApp" ng-controller="AppCtrl"> <form name="myForm"> <md-datepicker name="startDate" md-is-error="myForm.startDate.$invalid && myForm.$submitted" ng-model="startDate" md-placeholder="Start date" required flex="100" flex-lg="50"></md-datepicker> <div class="validation-messages" ng-messages="myForm.startDate.$error"> <div ng-message="valid">The entered value is not a date!</div> <div ng-message="required">This date is required!</div> <div ng-message="mindate">Date is too early!</div> <div ng-message="maxdate">Date is too late!</div> </div> </form> <script type="text/javascript"> var app = angular.module("testApp", ["ngMaterial","ngMessages"]) .controller('AppCtrl', function($scope) { $scope.startDate= null; </script> </body> </html>
source share