title: How to create custom directive for email format in Angular JS
body: <p>I want to create directive for email format (i.e. all validation in the project).</p>
  
  <p>First I have used below code</p>
  
  <pre><code> &lt;input type="email" class="form-control" name="UserName" ng-model="userDetail.UserName" placeholder="Enter email" ng-pattern="/^[_a-z0-9]+(\.[_a-z0-9]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/" required&gt; 
  </code></pre>
  
  <p>This working But I need to declare this <code>"/^[_a-z0-9]+(\.[_a-z0-9]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/"</code> in the whole project where used email address.</p>
  
  <p>In future, I need to change pattern for email address. So, I need to find all email field in project after change every field pattern in the project. But My goal - How I can do this pattern global for the project.</p>
  
  <p>I think, it is possible with custom directive. </p>
  
  <p>So my question. How I can create directive for email pattern.   </p>