title: Angular2 email validation
body: <p>I am new in learning Angular2, and I want to make a validation form that verifies emails after a RegEx pattern.</p>
  
  <p>My code looks something like this but I don't have any idea if I am doing it right, or what I did wrong, can somebody please help me a bit?</p>
  
  <p>Thank you!</p>
  
  <p>I fixed it. Thank you a lot everybody.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="alert-email"&gt;
      &lt;label for="contactemail"&gt;EMAIL: &lt;/label&gt;
      &lt;input type="email" id="contactemail" name="contactemail"
             required ng-pattern="/^[a-zA-Z0-9.!#$%&amp;’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/"
             [(ngModel)]="model.contactemail" #contactemail="ngModel"
             placeholder="Your email" /&gt;&lt;br&gt;&lt;br&gt;
      &lt;div *ngIf="contactemail.errors &amp;&amp; (contactemail.dirty || contactemail.touched)" class="alert-email alert-danger-email"&gt;&lt;br&gt;
        &lt;div [hidden]="!contactname.errors.required"&gt;
          Email is required
        &lt;/div&gt;
        &lt;div [hidden]="!contactname.errors"&gt;
          Please input a valid email.
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>