Search code examples
javascriptangularjsangular-moment

How to set today date and time as default in angular-moment-picker


I am using angular-moment-picker input for datetimepicker, and I want to set today date and current time on the input. Here is my source code. can you please help me. Thank you

 <input class="form-control"
                       format="DD/MM/YYYY HH:mm"
                       ng-model-options="{ updateOn: 'blur' }"
                       moment-picker="startDate"
                       id="startDate"
                       ng-model="startDate"> 

Solution

  • set default value startDate when controller initialized

    angular
      .module('Demo', ['moment-picker'])
      .controller('DemoController', ['$scope', function ($scope) {
    
          $scope.startDate = moment();
      }]);