I am getting response from backend LastDate
. I am binding this to my ngModel
and showing in Grid, but in console I am getting this error
Here is the corresponding code
<ngx-datatable-column name="Last Date" prop="LastDate">
<ng-template let-row="row" ngx-datatable-cell-template>
{{row.LastDate| date: 'dd-MM-yyyy'}}
</ng-template>
</ngx-datatable-column>
The date (
String
)"14-05-2021"
would be interpreted wrongly by Javascript. It accepts date in the format "MM-DD-YYYY" whereas your input is in the format "DD-MM-YYYY". The quick fix would be to reformat the string before sending it to thedate
pipe.Controller (*.ts)
This way the
LastDate
property of therow
object is adjusted to be of the expected format "MM-DD-YYYY".Obviously the transformation is trivial using
Array#split
. I'm sure someone else could come up with a better solution (eg. using RegEx).