I have integrated a plugin with Angular, which is essentially an extension. Upon loading the view, only an empty input is visible. Clicking on the input reveals a calendar with today's date displayed.
My objective is to automatically load today's date in the input when the view is loaded.
This is how I am currently using it:
<input type='text' datetimepicker
datetimepicker-options="{format: 'MM/DD/YYYY', useCurrent: true}"/>
Any suggestions on how to achieve this?
EDIT
I tried adding autofocus
to the input, but it causes the datepicker to show up immediately, whereas I need just the date to be displayed.
MY CONTROLLER:
(function () {
'use strict';
angular
.module('palpatine')
.controller('RotationsCtrl', RotationsCtrl);
/* @ngInject */
function RotationsCtrl (Rotations, $scope, $rootScope, $state) {
/*jshint validthis: true */
var vm = this;
activate();
function activate () {
$(document).ready(function () {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
dd='0'+dd
}
if(mm<10) {
mm='0'+mm
}
today = mm+'/'+dd+'/'+yyyy;
$scope.today = moment().format("MM/DD/YYYY");
console.log(today);
$scope.datetimepickerOptions = {
format: 'MM/DD/YYYY',
defaultDate: today
};
});
}
}
})();