How to set the today's date in datepicker textbox in angularjs

I am not sure what you mean by a datepicker textbox. Are you using a date input?

<input name="dateInput" type="date" ng-model="date"/>

If so in the controller you need to set the ng-model variable, in this case, $scope.date to the default date you want to use e.g. to use today's date

var d=new Date();
var year=d.getFullYear();
var month=d.getMonth()+1;
if (month<10){
month="0" + month;
};
var day=d.getDate();
$scope.date=year + "-" + month + "-" + day;

I have set up a plunkr at http://plnkr.co/edit/WJ86aB?p=preview


If so in the controller you need to set the ng-model variable, in this case, $scope.date to the default date you want to use e.g. to use today's date

$scope.date = new Date();

In your html:

<input name="dateInput" type="date" ng-model="date"/>

Tags:

Angularjs