Is there a way to set a default date in a specific id of an HTML element? I am currently using datetimepicker in AngularJS directives, but I'm struggling to set the default date in my id.
timeTracker.directive('datetimepicker', function($parse) {
var date = new Date();
var newdate = date.setDate(date.getDate() - 1);
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, element, attrs, ngModelCtrl) {
element.datetimepicker({
format: "DD-MM-YYYY",
defaultDate: new Date(newdate),
maxDate:new Date(),
}).on('dp.change', function(e) {
var Reportdate = $parse(attrs.ngModel);
Reportdate.assign(scope, e.target.value);
scope.ReportModel.Reportdate = e.target.value;
scope.$apply()
})
}
};
});
Is there a way to set a default date in an HTML element?