【问题标题】:How to disable Today and future dates in angular by using ngx-bootstrap datepicker?如何使用 ngx-bootstrap datepicker 以角度禁用今天和未来的日期?
【发布时间】:2021-01-21 21:19:24
【问题描述】:

我是 Angular 的新手。 有人可以帮忙吗?

要禁用今天和未来的日期,我使用了此代码?

<input class="form-control"
           placeholder="Datepicker"
           ngModel
           bsDatepicker
           [minDate]="minDate"
           [maxDate]="maxDate">

但是我没有在文本框中获取日历.. 谁能告诉我我犯了什么错误?

【问题讨论】:

    标签: angular


    【解决方案1】:
    dob: Date;
    public maxDob: Date;
    const year = this.dob.getFullYear() - 18;
    const month = this.dob.getMonth();
    const date = this.dob.getDate();
    this.maxDob = new Date(year, month, date);
    
    formInitialization(customerDetail ? : any) {
        dateOfBirth: [customerDetail ? customerDetail.dateOfBirth : ''],
    }
    
      <div class="col s4">
       <mat-form-field appearance="outline" class="common-form-field-width">
          <input readonly #dateFormat matInput 
          formControlName="dateOfBirth" [max]="maxDob" [matDatepicker]="picker" 
          placeholder="Date of Birth">
          <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
          <mat-datepicker #picker></mat-datepicker>
       </mat-form-field>
    </div>
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-27
      • 1970-01-01
      • 1970-01-01
      • 2017-08-21
      • 2014-05-01
      • 1970-01-01
      • 2022-01-19
      • 2011-10-24
      相关资源
      最近更新 更多