javascript – Angular 8 ng-reflect-model shows correct date value but not reflecting in input-ThrowExceptions

Exception or error:

Using

<div class="ui-g-12 ui-md-12">
  <input
    id="licenseForEdit.issuedDate"
    type="date"
    name="licenseForEdit.issuedDate"
    pInputText
    placeholder="License Issued Date"
    [(ngModel)]="licenseForEdit.issuedDate"
    required
    [class.field-error]="form.submitted && !licenseForEdit.issuedDate"
  />
</div>

I get:

<input _ngcontent-atp-c10="" id="licenseForEdit.issuedDate" name="licenseForEdit.issuedDate" pinputtext="" placeholder="License Issued Date" required="" type="date" ng-reflect-required="" ng-reflect-name="licenseForEdit.issuedDate" ng-reflect-model="2019-01-01T00:00:00" class="ng-pristine ng-valid ng-touched">

Yet, the input field remains: DatePattern
How do I get the Model’s value to display in the input box? I suspect that it’s a databinding issue, but…

How to solve:

First please check if the format is correct.

Find the reference for MDN here.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date.

In case the value needs to be transformed for display purpose please use pipe.

https://angular.io/guide/pipes

Leave a Reply

Your email address will not be published. Required fields are marked *