title: Prevent angular2 app from crashing due to invalid date (maybe override DatePipe?)
body: <p>I basically have an HTML5 date picker like this:</p>
  
  <pre><code>&lt;input class="form-control" type="date" [(ngModel)]="startDate" /&gt;
  </code></pre>
  
  <p>And another area that displays the date from the model like this:</p>
  
  <pre><code>{{startDate | date:shortDate}}
  </code></pre>
  
  <p><strong><em>I don't think it's relevant</em></strong> to this question but to be thorough, I have this kind of thing behind the scenes:</p>
  
  <pre><code>private startDate: string;
  private endDate: string;
  
  updateDateFilter() {
      let from = new Date(this.startDate);
      let to = new Date(this.endDate);
      **Stuff to filter based on date range**
  }
  </code></pre>
  
  <p>It's awesome. There's a lot more going on but it'd probably be extraneous detail.</p>
  
  <p>The trouble is you can click into the date picker and, say, select the year and hit delete which does this:</p>
  
  <p><a href="https://i.stack.imgur.com/KbeE3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KbeE3.png" alt="Bad Date"></a></p>
  
  <p>No problem right? Wrong, because the Angular2 date pipe gets confused and my whole app crashes after displaying this surprisingly helpful error message:</p>
  
  <blockquote>
    <p>ORIGINAL EXCEPTION: Invalid argument '' for pipe 'DatePipe'</p>
  </blockquote>
  
  <p>The solution seems simple but I'm not sure how to go about it. I'm thinking I just need to catch the date string before it's processed by the DatePipe and make sure there's valid content for the day, month, and year. But Angular2 does magic and the since it's done using model binding I don't see a clear route to intervention.</p>
  
  <p>I probably need to override the DatePipe, keeping its functionality but checking the string first. I don't know how. If you know how to do that, do share. Any alternative approaches would be helpful too. I just can't have the app crash whenever the date is incomplete.</p>
  
  <p>Thanks!</p>