Get current date using angularjs

I am using HTML5 calendar control for date selection and trying to display current system date initially when the user navigates to this page using angularjs.I have tried below code but not getting date in the calendar control.What is the wrong with below code?

<div ng-app ng-controller="Ctrl">
<label>From Date</label>
<input type="date" id=FromDate" name="FromDate"  ng-model="FromDate" date-format="yyyy-MM-dd"/>
</div>

function Ctrl($scope)
{
    $scope.FromDate = new Date();
}

new Date() returns object, not a string

Try this:

var date = new Date();
$scope.FromDate = date.getFullYear() + '-' + ('0' + (date.getMonth() + 1)).slice(-2) + '-' + ('0' + date.getDate()).slice(-2);

Thank you so much

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.