title: Prevent user from entering future date angular 4
body: <p>i have an object of dateOfBirth and i created an object of today's date with moment js 
  but when i compare them it gives me an error even if date entered is smaller than today's date </p>
  
  <p><strong>here is my html file</strong></p>
  
  <pre><code>&lt;div class="form-group datepicker"&gt;
        &lt;label for="dob"&gt;Date of Birth*&lt;/label&gt;
        &lt;div class="row input-group"&gt;
          &lt;input
            ngbDatepicker
            #d="ngbDatepicker"
            #dobF="ngModel"
            class="form-control input-underline input-lg"
            id="dob"
            [(ngModel)]="dateOfBirth"
            placeholder="yyyy-mm-dd"
            name="dp"
            [ngClass]="{
              invalid:
                (dobF.value === null || isString(dobF.value) || (dateOfBirth.year &gt; dobYear || dateOfBirth.month &gt; dobMonth || dateOfBirth.day &gt; dobDay) ) &amp;&amp; dobF.touched
            }"
            required
          /&gt;
          &lt;div class="input-group-append"&gt;
            &lt;button
              class="btn btn-outline-secondary calendar"
              (click)="d.toggle()"
              type="button"
            &gt;&lt;/button&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div
          *ngIf="
            (dobF.value === null || isString(dobF.value)  || dateOfBirth.year &gt; dobYear || dateOfBirth.month &gt; dobMonth || dateOfBirth.day &gt; dobDay ) &amp;&amp; dobF.touched
          "
          class="error"
        &gt;
          Please enter a valid date of birth.
        &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p><strong>here is my ts file where i defined my code of dob</strong></p>
  
  <pre><code> public dateOfBirth: { year: number; month: number; day: number };
   public currentDate = moment().format("YYYY-MM-DD");
   public dobYear: any;
   public dobMonth: any;
   public dobDay: any;
  
    let obj = this.currentDate.split("-");
  let obj2 = obj.map(Number);
  this.dobYear = obj2[0];
  this.dobMonth = obj2[1];
  this.dobDay = obj2[2];
  </code></pre>
  
  <p>it is giving me an error because today's month is 02 so when i enter 2012-09-09 it gives me an error because 02&lt;09 
  so how to prevent this error?
  can anyone help me? thanks</p>