I'm working on converting an older .cshtml view file into pure HTML + TypeScript using Angular1. In this instance Angular really hasn't much to do with the issue as much as finding the equivalent functionality in TypeScript (or JavaScript) from some C# code within a Razor view.
The old code was the following:
ng-init="
vm.defaultStartDate='@SqlDateTime.MinValue.Value'; vm.defaultEndDate='@SqlDateTime.MaxValue.Value'"
In the updated code, these values will not be set in the view; there's no reason for that. The Angular controller logic written in TypeScript can initialize these values and use them when required. The problem is, I'm trying to figure out the equivelent code in TypeScript/JavaScript and I can't seem to come up with the correct implementation.
According to the MSDN, @SqlDateTime.MinValue.Value will equate to the following:
The minimum valid date for a SqlDateTime structure is January 1, 1753
And from the MSDN for @SqlDateTime.MaxValue.Value:
The maximum valid date for a SqlDateTime structure is December 31, 9999.
I've tried the following, but when executed I'm getting an issue on the server that the dates are not defined properly. When I debug in TypeScript they don't match the original versions either.
this.defaultStartDate = String(new Date('1/1/1753'));
this.defaultEndDate = String(new Date('12/31/9999'));
Certainly there is a better way I can initialize those dates and I'm sure I'm missing something trivial. What's the best way to set those dates using TypeScript/JavaScript to be essentially the bookend start/end default dates that the old C# code was doing?