title: Validate a form using Angular-material
body: <p>How Can I validate a form using Angular-material, I need two functionalities:
  1) When click submit show error messages if required fields are empty.
  2) Do not send post request(avoid submit) if form fields are not valid.
  The next code avoid submit but it does not show error messages when clicking, only when cursor is going out of each input field.</p>
  
  <pre><code> &lt;form name="userForm"&gt;
  &lt;md-input-container&gt;
      &lt;input name="email" placeholder="Email" data-ng-model="vm.registerUserData.email" required /&gt;
      &lt;div ng-messages="userForm.email.$error" ng-if='userForm.myControl.$dirty'&gt;
        &lt;div ng-message="required"&gt;This is required!&lt;/div&gt;
      &lt;/div&gt;
  &lt;/md-input-container&gt;
  
  &lt;md-input-container&gt;
      &lt;input name="Password" placeholder="Password" data-ng-model="vm.registerUserData.password" required /&gt;
       &lt;div ng-messages="userForm.Password.$error"&gt;
       &lt;div ng-message="required"&gt;This is required!&lt;/div&gt;
       &lt;/div&gt;
   &lt;/md-input-container&gt;                             
  
   &lt;md-input-container&gt;
      &lt;md-button id="registerUser" value="Register" class="md-raised md-primary" ng-click="userForm.$valid &amp;&amp;  vm.registerUser()" aria-label="login" ng-disabled="login.loginForm.$invalid()"&gt;
        Create
       &lt;/md-button&gt;
  &lt;/md-input-container&gt;
   &lt;/form&gt;
  </code></pre>