title: angular 2 form validation giving undefined error message
body: <p>I followed the angular 2 tutorial and tried to implement validation in a angular 2 form. See code:</p>
  
  <pre><code>&lt;form #loginForm="ngForm" (ngSubmit)="login()"&gt;
      &lt;div&gt;
          &lt;label for="email"&gt;Email:&lt;/label&gt;
          &lt;input type="text" id="email" name="email" required minlength="4" maxlength="24" [(ngModel)]="emailField" #name="ngModel" /&gt;
          &lt;div *ngIf="email?.errors &amp;&amp; (email?.dirty || email?.touched)" class="alert alert-danger"&gt;
              &lt;div [hidden]="!email.errors.required"&gt;
                email is required
              &lt;/div&gt;
              &lt;div [hidden]="!email.errors.minlength"&gt;
                email must be at least 4 characters long.
              &lt;/div&gt;
              &lt;div [hidden]="!email.errors.maxlength"&gt;
                Name cannot be more than 24 characters long.
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;  
      &lt;div&gt;
          &lt;label&gt;Password:&lt;/label&gt;&lt;input type="password" name="password" [(ngModel)]="passwordField" /&gt;
      &lt;/div&gt;
      &lt;div&gt;
          &lt;button [disabled]="!loginForm.form.valid" type="submit"&gt;Submit&lt;/button&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The problem is that I am getting this error code : </p>
  
  <pre><code>ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'errors' of undefined
  </code></pre>
  
  <p>I tried to implement it exactly as in the tutorial on the official site: <a href="https://angular.io/docs/ts/latest/cookbook/form-validation.html#!#template1" rel="nofollow noreferrer">https://angular.io/docs/ts/latest/cookbook/form-validation.html#!#template1</a></p>