【发布时间】: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