title: Creating a error component in Angular2/4
body: <p>I'm fairly new to Angular and I am stuck. </p>
  
  <p>I have a form which when a user doesn't fill the required fields gives an error on submit. Instead of giving an error on the page (like the attachment), I want this error to show up on a modal. </p>
  
  <p>Like when a user doesn't fill the required fields and hit submits, a modal appears giving us the error telling us what went wrong.</p>
  
  <p>How would I create an error modal? I want to create a new component for this error because I want to be able to use this component on various pages. </p>
  
  <pre><code>onSubmit() {
    //do something 
    }, err =&gt; {
       //How would I make my error component open when there is an error here.
       console.log("err");
    }
  }  
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/OpvMh.png" rel="nofollow noreferrer">error</a></p>