ngx bootstrap datepicker:如何更改工作日?

时间:2018-11-01 19:19:38

标签: datepicker ngx-bootstrap

如何更改ngx引导程序日期选择器中的工作日?

来自:周一,周二,周三,周四,周五,周六,周日 收件人:M,T,W,T,F,S,T

有人可以帮助我吗?

datepicker example

3 个答案:

答案 0 :(得分:2)

感谢Himanshu,

我能够解决此问题:

import { Component, OnInit } from '@angular/core';
import { setTheme } from 'ngx-bootstrap/utils';
import { BsLocaleService } from 'ngx-bootstrap/datepicker';
import { defineLocale } from 'ngx-bootstrap/chronos';
import { enGbLocale } from 'ngx-bootstrap/locale';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
  title = 'app';

  constructor(private localeService: BsLocaleService) {
    setTheme('bs4');
    enGbLocale.weekdaysShort = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];
    enGbLocale.week.dow = 0;
    defineLocale('en', enGbLocale);
  }

  ngOnInit() {
    this.localeService.use('en');
  }

}

答案 1 :(得分:0)

就我而言,我想使用西班牙语

import { Component, OnInit } from '@angular/core'; 
import { setTheme } from 'ngx-bootstrap/utils'; 
import { BsLocaleService } from 'ngx-bootstrap/datepicker'; 
import { defineLocale } from 'ngx-bootstrap/chronos'; 
import { esDoLocale } from 'ngx-bootstrap/locale';

@Component({   selector: 'app-root',   templateUrl: './app.component.html',   styleUrls: ['./app.component.scss'] }) export class AppComponent implements OnInit {   title = 'app';

  constructor(private localeService: BsLocaleService) {
    esDoLocale.weekdaysShort = ['L', 'M', 'M', 'J', 'V', 'S', 'D'];
    esDoLocale.week.dow = 0;
    defineLocale('es', esDoLocale);   }

  ngOnInit() {
    this.localeService.use('es');   }

}

答案 2 :(得分:0)

这对我有用(en-gb)

constructor(private localeService: BsLocaleService) {
    enGbLocale.weekdaysShort = ["S", "M", "T", "W", "T", "F", "S"];
    enGbLocale.week.dow = 0;
    defineLocale("en-gb", enGbLocale);
}

ngOnInit() {
   this.localeService.use("en-gb");
}

stackblitz