Allow Moment.js dates in bootstrap-ui datepicker

前端 未结 2 574
后悔当初
后悔当初 2021-02-13 19:18

I\'m trying to use Bootstrap UI\'s DatePicker with Moment.js dates.

It is possible if I convert my model value from Moment.js date to standard Date prior to

2条回答
  •  时光取名叫无心
    2021-02-13 19:50

    Decorating the original datepickerPopup and datepicker directives it's possible to achieve this conversion.

    In this plunker I've changed the following methods:

    • ngModel.$render on datepickerPopup;
    • parseDate on datepickerPopup;
    • minDate and maxDate $watches on datepicker;
    • this.render on datepicker;
    • this.refreshView on datepicker;
    • this.createDateObject on datepicker;
    • $scope.select on datepicker;

    with moment.utc() and I'm pretty satisfied with the results. Let me know if it works for you.

提交回复
热议问题