Change Angular ui-bootstrap datepicker day order

2019-04-10 20:58发布

问题:

Currently the ui-bootstrap datepicker popup orders the days of the week Mon-Sun. I have a request from a customer to reorder them Sun-Sat

Interestingly, on the ui-bootstrap page, the inline example has the Sun-Mon order but the popup is Mon-Sun.

Is there a way to change the day order in the popup? I have not found any info on that topic in my googling.

回答1:

Andrew, in the Datepicker docs, under the "Popup Settings" subheading, it says "Options for datepicker can be passed as JSON using the datepicker-options attribute", which was the key piece for me in tackling the same problem you're facing.

See this JSFiddle, which simplifies the example code from angular-ui.github.io, and contains the bits I think you need. Note that you need to change to camel case "startingDay" spelling:

$scope.dateOptions = {
  formatYear: 'yy',
  showWeeks: false,      
  startingDay: 0
};


回答2:

That plugin has 'starting-day' as an option. Setting that to 0 will make it start on Sunday.

http://angular-ui.github.io/bootstrap/#/datepicker