md-date-picker没有显示当前月AngularJs

时间:2017-02-27 06:45:43

标签: javascript html angularjs

我正在使用Angularjs md-datepicker作为日历 当我点击日期选择器时,我希望显示当前月份 但是,datepicker没有显示当前月份。

你能找到我的代码有什么问题吗?感谢

<div class="col-md-3" style="margin: 18px 0;">
    <md-datepicker ng-model="formData.startAt1" ng-required="true" md-max-date="formData.endAt1" md-placeholder="Enter start date">
    </md-datepicker>
    <div class="row" id="startDateError" style="display: none">
        <div class="col-md-12" style="color: #FF5252;margin-top: 6px;font-weight: 600;">* Please select start date.</div>
    </div>
</div>

控制器

scope.formData = {
       startAt1: "",
       endAt1: ""
        };

1 个答案:

答案 0 :(得分:0)

没有md模型,它应该是ng-model,

   <md-datepicker ng-model="myDate" md-placeholder="Enter date"></md-datepicker>

<强>样本

angular.module('datepickerBasicUsage', ['ngMaterial'])
.controller('AppCtrl', function ($scope) {
  
});
<!doctype html>
<html ng-app="datepickerBasicUsage">

<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular-animate.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular-aria.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.4/angular-material.js"></script>
  <script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-114/assets-cache.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.4/angular-material.css">
  <script src="app.js"></script>
</head>

<body>
  <div ng-controller="AppCtrl" style='padding: 40px;'>
    <form ng-submit='angular.noop'>
      <md-content>
        <h4>Standard date-picker</h4>
        <md-datepicker ng-model="myDate" md-placeholder="Enter date"></md-datepicker>
      </md-content>
    </form>
  </div>
</body>

</html>