Ion-datetime with form builder

How to use ion-datetime with form builder. If you use ng-model as shown in docs you can not use it with Angular2 form builder.

It works fine with formControlName for me.

Thanks, the issue was using ngModel with form builder but silly me I did not think of using it just like any form group item. So yes it works.

I ran into this today… just in case the next guy comes around with the same issue…

Here’s a fix from the entry dated May 11, 2017 at this site https://github.com/ionic-team/ionic/issues/7270:

Bug: ng-valid / ng-dirty not working on ion inputs other than ion-input

For anyone looking for a workaround for this:

<ion-item>
      <ion-label stacked>label</ion-label>
      <ion-input  formControlName="issueDateValidator" class="hotfix" ></ion-input>
      <ion-datetime formControlName="issueDateValidator" [min]="minimumIssueDate" displayFormat="DD/MM/YYYY" [(ngModel)]="date_var"></ion-datetime>
 </ion-item>

in css:

ion-input.hotfix{
        display: none;
}