Is it possible to pass a piped date as an argument for a function?
I am thinking of something along the lines of...
date: string
that will be assigned a value passed from a datepicker Fri Feb 09 2018 00:00:00 GMT+0000 (GMT Standard Time)
date | date:'yyyy-MM-dd'
date | date:'yyyy-MM-dd'
I am wanting to pass into a function, that piped date - something like:
someFunction(date | date:'yyyy-MM-dd');
Is there any way that this could be possible?
Or will I have to pass the original long date into a function, mutate it and then use it?
I have since found a way to just JS it - How do I get a date in YYYY-MM-DD format?
This splits the date and then recombines it into a string:
onSelect(theDate: Date): void {
var yyyy = theDate.getFullYear().toString();
var mm = (theDate.getMonth()+1).toString();
var dd = theDate.getDate().toString();
var mmChars = mm.split('');
var ddChars = dd.split('');
var dateString = yyyy + '-' + (mmChars[1]?mm:"0"+mmChars[0]) + '-' + (ddChars[1]?dd:"0"+ddChars[0]);
this.meetingService.getMeetingsByDate(dateString);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.