Facing an issue with date properties in Angular. For instance, here is the Model I am working with:
export class Model{
dateFrom Date;
dateTo Date;
}
In my Create view, I have the following setup:
<input type="date" [(ngModel)] = "model.dateFrom">
<input type="date" [(ngModel)] = "model.dateTo">
<button type="button" (click)="save()"></button>
Within my typescriptFile, there is a function:
public save(){
if(model.dateFrom > model.dateTo){
//Display Error Message
}
}
The issue lies in model.dateFrom and model.dateTo being recognized as strings instead of Dates! I require several date comparisons before sending the data to .net web api. How can I convert string to date? How can I make Angular binding return a date type? What are the best practices for date validations in Angular projects???
I previously used moment.js for date validations in Jquery projects, but seeking advice for Angular project.
Your insights are appreciated!