【问题标题】:AngularJS date picker years and months onlyAngularJS 日期选择器仅年份和月份
【发布时间】:2017-08-16 14:46:53
【问题描述】:

我正在尝试将 angular ui 日期选择器配置为仅选择年份和月份,而不是显示日期,但我不能这样做。我能做些什么来实现这一点。 那是我的plnkr

http://plnkr.co/edit/JR2EuU?p=preview

angular.module('plunker', ['ui.bootstrap']);
var DatepickerDemoCtrl = function ($scope) {
  $scope.today = function() {
    $scope.dt = new Date();
  };
  $scope.today();

  $scope.showWeeks = false;


  $scope.open = function($event) {
    $event.preventDefault();
    $event.stopPropagation();

    $scope.opened = true;
  };

  $scope.dateOptions = {
    'year-format': "'yy'",
    'starting-day': 1,
    'datepicker-mode':"'month'",
    'min-mode':"month"
  };

}; 

这就是我的看法

<input type="text" class="form-control" datepicker-popup="MM/yyyy" ng-model="dt" is-open="opened" datepicker-options="{minMode: 'month'}" datepicker-mode="'month'" show-button-bar="false" show-weeks="false" close-on-date-selection="true" />
          <span class="input-group-btn">
    <button type="button" class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>

我在这里找到了这个解决方案,但我不想使用 Jquery,我希望使用 Angular js。 http://plnkr.co/edit/JUSAaQoFtU8Kw1KyvXwN?p=preview

【问题讨论】:

标签: angularjs datepicker


【解决方案1】:

在您的 plunker 中,当我将 angular-ui 从 0.10 升级到 0.12 时,它起作用了。将 index.html 中的第 5 行替换为

&lt;script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.0.js"&gt;&lt;/script&gt;

我找不到关于 0.10 版的文档。文档返回最远的是0.12

【讨论】:

    【解决方案2】:

    我使用了 indrimuska.github.io/angular-moment-picker,它运行良好,非常现代且易于配置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多