简体   繁体   English

用于下一个/上一个的 Angular Ngx-Bootstrap Datepicker 自定义按钮

[英]Angular Ngx-Bootstrap Datepicker Custom Buttons for Next/Previous

Our project is in process of updating Angular 4 to Angular 7. As part of this ng2-bootstrap was updated to ngx-bootstrap.我们的项目正在将 Angular 4 更新为 Angular 7。作为此 ng2-bootstrap 的一部分,已更新为 ngx-bootstrap。

Bootstrap version is 3, ngx-bootstrap is 5.3.2 Bootstrap 版本是 3,ngx-bootstrap 是 5.3.2

We are using the DatepickerModule, not the BsDatepickerModule.我们使用的是 DatepickerModule,而不是BsDatepickerModule。 In ng2-bootstrap the datepicker appeared to have glyphicons built in. Now they're gone.在 ng2-bootstrap 中,日期选择器似乎内置了字形。现在它们不见了。 The "Previous" and "Next" buttons used glyphicon-chevron-left and glyphicon-chevron-right. “上一个”和“下一个”按钮使用了 glyphicon-chevron-left 和 glyphicon-chevron-right。 Now they simply have "<" and ">" as text.现在他们只是将“<”和“>”作为文本。

Is there a way to set custom Previous and Next buttons in the ngx-bootstrap datepicker?有没有办法在 ngx-bootstrap 日期选择器中设置自定义上一个和下一个按钮? Or get it to use glyphicons?或者让它使用字形? (Or font awesome icons?) (或字体真棒图标?)

ng2: ng2:

ng2Datepicker

ngx: ngx:

ngx日期选择器

.html: .html:

<div style="float:left;" [ngStyle]="{'opacity': disabled ? '0.5' : '1'}">
    <div class="input-group">
        <input #endDateRef type="text" [disabled]="disabled" [class.has-error]="!endDateValid"
               placeholder="mm/dd/yyyy" maxlength="10" [ngStyle]="{'font-size' : !endDate ? '14px' : '15px'}"
               (keyup)="onEndDateKeyup()" (keyup.enter)="$event.target.blur()"
               (focus)="close()" (blur)="onExitDateInput('end')" class="{{small ? 'small' : ''}}">
        <span class="input-group-addon datepicker {{small ? 'small-icon' : ''}}" [class.has-error]="!endDateValid">
                <span class="glyphicon glyphicon-calendar" (click)="!disabled && (showEndPicker = !showEndPicker); showStartPicker = false"></span>
            </span>
    </div>
    <div *ngIf="showEndPicker"
         style="position: absolute; z-index:10; min-height:290px;">
        <datepicker [(ngModel)]="endDate"
                    [minDate]="minDate"
                    [maxDate]="maxDate"
                    (selectionDone)="datePicked('end')"
                    [showWeeks]="false">
        </datepicker>
    </div>
</div>

Update:更新:

I've managed to accomplish this by editing styles.scss but this seems a little hacky.我已经通过编辑styles.scss 设法实现了这一点,但这似乎有点笨拙。 If there's a better way I'd love to hear it.如果有更好的方法,我很想听听。

styles.scss:样式.scss:

daypicker > table > thead > tr > th {
  .pull-left {
    font-family: 'Glyphicons Halflings';
    font-size: 0px;
    &::before {
      content: "\E079";
      font-style: normal;
      font-size: 16px;
      font-weight: 400;
      line-height: 1;
      display: inline-block;
      position: relative;
      top: 1px;
      box-sizing: border-box;
    }
    &::after {
      box-sizing: border-box;
    }
  }

  .pull-right {
    font-family: 'Glyphicons Halflings';
    font-size: 0px;
    &::before {
      content: "\E080";
      font-style: normal;
      font-size: 16px;
      font-weight: 400;
      line-height: 1;
      display: inline-block;
      position: relative;
      top: 1px;
      box-sizing: border-box;
    }
    &::after {
      box-sizing: border-box;
    }
  }
}

Apparently there isn't a better way to accomplish this.显然没有更好的方法来实现这一点。 I edited the styles.scss to get it working:我编辑了 style.scss 以使其正常工作:

daypicker > table > thead > tr > th {
  .pull-left {
    font-family: 'Glyphicons Halflings';
    font-size: 0px;
    &::before {
      content: "\E079";
      font-style: normal;
      font-size: 16px;
      font-weight: 400;
      line-height: 1;
      display: inline-block;
      position: relative;
      top: 1px;
      box-sizing: border-box;
    }
    &::after {
      box-sizing: border-box;
    }
  }

  .pull-right {
    font-family: 'Glyphicons Halflings';
    font-size: 0px;
    &::before {
      content: "\E080";
      font-style: normal;
      font-size: 16px;
      font-weight: 400;
      line-height: 1;
      display: inline-block;
      position: relative;
      top: 1px;
      box-sizing: border-box;
    }
    &::after {
      box-sizing: border-box;
    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM