如何更改启动日历中的“今天”按钮标签

时间:2019-12-04 03:20:02

标签: angular primeng

primeng calendar

我正在使用启动版本7.1.3。在这种情况下,我正在使用p-calendar,并且如果我指定showButtonBar =“ true”,那么我会得到今天的提示并清除按钮。我需要更改“今日”按钮的标签。我该如何实现?

.html

 <div [formGroup]="plf.cueForm">
   <p-calendar 
   #myCalendar 
   [dataType]="'string'" 
   (onTodayClick)="onTodayClick($event)" 
   formControlName="{{itemId}}"  
   [timeOnly]="true" 
   [placeholder]="'HH:MI'" 
   [showIcon]="true" 
   showButtonBar="true"
   appendTo="body"
   icon="fa fa-calendar"></p-calendar>
  </div>

1 个答案:

答案 0 :(得分:1)

您可以使用区域设置属性立即更改/清除按钮的文本。

所以代码看起来像这样,

<p-calendar 
   #myCalendar 
   [dataType]="'string'" 
   (onTodayClick)="onTodayClick($event)" 
   [(ngModel)]="value"  
   [timeOnly]="true" 
   [placeholder]="'HH:MI'" 
   [showIcon]="true" 
   showButtonBar="true"
   appendTo="body"
   icon="fa fa-calendar"
   [locale]="en"></p-calendar>

ngOnInit() {  

    this.en = {
      firstDayOfWeek: 0,
      dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
      dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
      dayNamesMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
      monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
      today: 'Custom Today',
      clear: 'Clear it !!!'
    };
  }

这里是演示-https://stackblitz.com/edit/prime-ng-calendar-sysnhm 希望这会有所帮助