Zależy mi aby komunikaty o błędach były odseparowane od stryktury formularza, tak jak jest obecnie.
<html ng-app="formApp"> <head > <meta charset="utf-8"> <style> </style> </head> <body ng-controller="MainCtrl as ctrl"> <form ng-submit="ctrl.submit()" name="form1"> <input type="email" name="f1_email" ng-model="ctrl.user.email" ng-minlength="10" required> <div ng-messages="form1.f1_email.$error" ng-show="form1.f1_email.$submitted || form1.f1_email.$touched "> </div> <hr> <input type="text" name="f1_name" ng-model="ctrl.user.name" ng-minlength="6" required> <div ng-messages="form1.f1_name.$error" ng-show="form1.f1_name.$submitted || form1.f1_name.$touched "> <div ng-messages-include="error-messages"> </div> </div> <hr> <input type="submit" value="Send" ng-disabled="form1.$invalid"> <hr> </form> <hr> <script type="text/ng-template" id="error-messages"> </script> <script> angular.module('formApp',['ngMessages']) .controller('MainCtrl', [function() { var self = this; self.submit = function() { console.log('User data', self.user); }; }]); </script> </body> </html>