【问题标题】:initDate Issue in angular ui bootstrap DatePicker角度 ui 引导程序 DatePicker 中的 initDate 问题
【发布时间】:2015-03-18 07:29:49
【问题描述】:

我有 datepicker ,我想在其中配置 initDate 以便如果模型值为 null 则 datepicker 显示默认选定日期。 这是 HTML:

<span class="input-group">
      <input type="text" id="input_empdob"  ng-readonly="isEmployeeRelieved" readonly placeholder="mm/dd/yyyy" min="mindobDate" max="maxdobDate" ng-change="setYearOfPassing(); setJoiningDate();" class="form-control" datepicker-popup="{{format}}" ng-model="employee.dob" datepicker-options="dateOptions" is-open="emp_dob_opened" ng-required="true" close-text="Close" name="input_empdob"/>
             <span class="input-group-btn">
                   <button class="btn btn-default" ng-click="open($event); emp_dob_opened = true;"><i class="glyphicon glyphicon-calendar"></i></button>
             </span>

并且在控制器中我已经配置了 datepicker-options 像:

$scope.dateOptions = {
            'init-date': new Date(1991,01,02)
        };

第一次加载时表现良好,但在保存时,当我清除模型值时,它不会按照配置正确显示 initDate。

感谢您的帮助。

【问题讨论】:

  • 清除模型后不显示initDate是什么意思?
  • 这里有一个悬而未决的拉取请求issue2331
  • @pankajparkar 当我清除 employee.dob 它应该显示 1991-01-02 作为默认选择日期,但它没有。

标签: angularjs datepicker angular-ui-bootstrap


【解决方案1】:

我也试过了,没用。

所以,我正在对模型使用初始化。

在我的控制器中,我将其设置为:

$scope.initialDate: $filter('date')(new Date(), 'dd/MM/yyyy');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-14
    • 2019-05-13
    • 1970-01-01
    • 1970-01-01
    • 2018-03-17
    相关资源
    最近更新 更多