格式日期选择器未更改 angularjs

Format datepicker not change angularjs

我已经为我的日期选择器定义了这样的格式

    $scope.open1 = function() {
    $scope.popup1.opened = true;
  };

  $scope.open2 = function() {
    $scope.popup2.opened = true;
  };
  $scope.formats = ['dd-MMMM-yyyy', 'yyyyMMdd'];
  $scope.format = $scope.formats[1];
  $scope.dt = new Date();
  $scope.dt2 = new Date();
  console.log($scope.dt);
  $scope.popup1 = {
    opened: false
  };

  $scope.popup2 = {
    opened: false
  };

但是当我console.log时,结果变成了这样

我想要像 console.log 这样的结果,结果将与我定义的相同。例如 Tue Nov 14 2017 变成 20171114

这是我的 .html 文件

<div class="col-md-2">
        <p class="input-group">
          <input type="text" class="form-control" uib-datepicker-popup="{{format}}" ng-model="dt2" is-open="popup2.opened"/>
          <span class="input-group-btn">
            <button type="button" class="btn btn-default" ng-click="open2()"><i class="glyphicon glyphicon-calendar"></i></button>
          </span>
        </p>
        </div>

对我有用,希望对你有帮助

var d = new Date($scope.dt);
  var curr_year = d.getFullYear();
  var curr_Month = d.getMonth()+1;
          if (curr_Month.toString().length < 2) {
            var curr_Month = "0" + (d.getMonth()+1);
          } else {
            var curr_Month = d.getMonth()+1;
          }
          //alert(curr_Month);

          var curr_date = d.getDate();
          if (curr_date.toString().length<2) {
            var curr_date = "0"+ d.getDate();
          } else {
            var curr_date = d.getDate();
          }
          //alert(curr_date);
          var todayDate = (curr_year + "" + (curr_Month) + "" + curr_date);