angular - Angular Ngx-Bootstrap Datepicker 下一个/上一个自定义按钮
问题描述
我们的项目正在将 Angular 4 更新为 Angular 7。作为此 ng2-bootstrap 的一部分,已更新为 ngx-bootstrap。
Bootstrap 版本是 3,ngx-bootstrap 是 5.3.2
我们使用的是 DatepickerModule,而不是BsDatepickerModule。在 ng2-bootstrap 中,日期选择器似乎内置了字形图标。现在它们不见了。“上一个”和“下一个”按钮使用 glyphicon-chevron-left 和 glyphicon-chevron-right。现在他们只是将“<”和“>”作为文本。
有没有办法在 ngx-bootstrap 日期选择器中设置自定义上一个和下一个按钮?或者让它使用字形图标?(或者字体很棒的图标?)
ng2:
ngx:
.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>
更新:
我已经设法通过编辑 styles.scss 来实现这一点,但这似乎有点 hacky。如果有更好的方法我很想听。
样式.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;
}
}
}
解决方案
显然没有更好的方法来实现这一点。我编辑了 styles.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;
}
}
}
推荐阅读
- python - 我该如何编写这个 django 查询?
- python - 来自 Kafka 的 pySpark Structured Streaming 不会输出到控制台进行调试
- python - 如何以 2x2 以外的模式将张量混合在一起?
- function - ARM 汇编语言中的两个函数/子程序
- java - 动态加载其实现时如何使接口成为仅编译依赖项
- android - 可以添加远程maven库,但是import语句失败
- javascript - 如何让两个不同的文本元素在 Javascript 中的页面上随机移动
- typescript - 为什么 eslint 在 Github Actions 上失败但在本地工作?
- electron - 如何处理电子应用程序中的请求(捕获请求,提供自定义响应)
- python - Alpha Vantage 每日信息调用导入错误