8 Answer(s)
-
0
Try
.toDate()
instead:[(ngModel)]="pssaleh.docDate.toDate()"
From https://momentjs.com/guides/#/lib-concepts/internal-properties:
As such, the values of
_d
and any other properties prefixed with_
should not be used for any purpose.To print out the value of a Moment, use
.format()
,.toString()
or.toISOString()
.To retrieve a native Date object from Moment, use
.toDate()
. This function returns a properly shifted date for interaction with third party APIs. -
0
Hi @aaron it is not working. I'm sharing code with you. please help me in this regard. actually on initialize I also want to show current date seleected.
HTML :
<input class="form-control m-input form-control-sm" [(ngModel)]="pssaleh.docDate.toDate()" type="datetime" bsDatepicker id="PSSALEH_DocDate" name="PSSALEH_DocDate">
TS :
ngOnInit() { this.pssaleh = new CreateOrEditPSSALEHDto(); this.pssaleh.docDate = moment(); }
Class :
export class CreateOrEditPSSALEHDto { docDate!: moment.Moment | undefined; }
kindly help me in this regard. As We have alot of date fields in our application
-
0
What's the error now?
-
0
-
0
That seems unrelated. Can you show the full line?
-
0
-
0
I was mistaken about
[(ngModel)]
.ASP<span></span>.NET Zero v7.2.0+ implements
datePickerMomentModifier
directive. Try this:- [(ngModel)]="pssaleh.docDate.toDate()" + datePickerMomentModifier + [(date)]="pssaleh.docDate"
-
0
This issue is closed because it has not had recent activity for a long time.