无法将默认的Angular uib-datepicker日期设置为null / empty

时间:2018-02-08 09:18:20

标签: javascript angularjs datepicker angular-bootstrap

我使用的Angular-bootstrap的版本是 0.14.2

问题:虽然我将 ng-model设置为“”或null,但设置为currentDate 。我希望它是空的。无法弄清楚是什么问题。

<input class="form-control" type="text"
       datepicker-append-to-body="true" uib-datepicker-popup="{{dateFormat}}"
       ng-model="businessJet.ExpirationDate"
       ng-change="info.updateRampFee(businessJet);"
       ng-click="businessJet.popupOpened = true"
       is-open="businessJet.popupOpened"
       ng-disabled="!businessJet.IsApplicable" />

1 个答案:

答案 0 :(得分:0)

将模型设置为null会将文本设置为空白。

http://plnkr.co/edit/KjkZi814j36jAbEr3x3y

$scope.dateFormat = 'dd-MMMM-yyyy';

$scope.businessJet = {
    ExpirationDate:null,
    updateRampFee: function(dateObj) {
        console.log('date changed',dateObj)
    },
    popupOpened : false,
    IsApplicable : true
};

<input class="form-control" 
      type="text"
      datepicker-append-to-body="true" 
      uib-datepicker-popup="{{dateFormat}}"
      ng-model="businessJet.ExpirationDate"
      ng-change="businessJet.updateRampFee(businessJet);"
      ng-click="businessJet.popupOpened = true"
      is-open="businessJet.popupOpened"
      ng-disabled="!businessJet.IsApplicable" />