【问题标题】:angular ui-datepicker in month mode not working when year is clicked单击年份时,月份模式下的角度 ui-datepicker 不起作用
【发布时间】:2014-07-14 13:56:24
【问题描述】:

在月份模式下点击年份我得到

与指令“datepicker”一起使用的表达式“月”是 不可分配!

在我的控制台中......我希望日历进入年份模式

这是我的 plnkr => PLNKR

我的html如下

<div ng-controller="DatepickerDemoCtrl">
      <h4>Month-Year Picker</h4>
      <div class="row">
        <div class="col-md-3">
          <p class="input-group">
            <input type="text" class="form-control col-md-3" 
                datepicker-popup="MMM-yyyy" 
                ng-model="dt" 
                is-open="opened" 
                close-on-date-selection="true" 
                datepicker-options="dateOptions" 
                date-disabled="disabled(date, mode)" 
                show-button-bar="false" 
                show-weeks="false" />
            <span class="input-group-btn">
              <button class="btn btn-default" ng-click="open($event)">
                <i class="glyphicon glyphicon-calendar"></i>
              </button>
            </span>
          </p>
        </div>
      </div>
    </div>

我的日期选项是

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

出了什么问题...请帮助...

【问题讨论】:

    标签: javascript angularjs datepicker angular-ui-bootstrap


    【解决方案1】:

    删除月份值周围的多余引号:

    'datepicker-mode':"month",
    

    你有:

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

    同样的问题:

    'year-format': "'yy'"
    

    【讨论】:

    • 试过了..不工作...你能在 plunker 上试试吗...LINK HERE
    • 这里除了其他人的建议外没有其他建议:stackoverflow.com/questions/23737270/angular-ui-month-picker
    • 真正的问题是现在不支持指定为文字字符串的模式。您必须使用绑定。这同样适用于其他选项 ['minDate', 'maxDate', 'datepickerMode', 'initDate', 'shortcutPropagation']。跟踪此issue
    【解决方案2】:

    试试

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

    【讨论】:

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