gpt4 book ai didi

angularjs - ui bootstrap datepicker替代日期格式

转载 作者:行者123 更新时间:2023-12-02 04:12:06 25 4
gpt4 key购买 nike

如何允许用户在输入表单中以不同格式键入日期?我看到选项 alt-input-formats。我尝试传递替代格式但没有结果。 Controller :

vm.altInputFormats = ['M!/d!/yyyy'];

标记:

        <div class="calendar">
<label>END DATE</label>
<input type="text"
ng-click="vm.toggleCalendar('endDate')"
class="calendar-control"
uib-datepicker-popup="{{'MM/dd/yy'}}"
ng-model="vm.dateFilter.endDate"
is-open="vm.endDateOpened"
datepicker-options="vm.datePickerOptions"
min-date="vm.dateFilter.startDate"
max-date="vm.currentDate"
show-button-bar="false"
alt-input-formats="vm.altInputFormats"
close-text="Close" />
<i ng-click="vm.toggleCalendar('endDate')" class="glyphicon glyphicon-calendar calendar-btn"></i>
</div>

现在我只能以这种格式输入日期:01/01/16,但对于 01/01/2016 我在模型中未定义。我的代码有什么问题吗?

最佳答案

altInputFormats 不应作为属性提供,而应作为 datepicker-options 配置对象的一部分提供。对于您的情况:

<input type="text"
ng-click="vm.toggleCalendar('endDate')"
class="calendar-control"
uib-datepicker-popup="{{'MM/dd/yy'}}"
ng-model="vm.dateFilter.endDate"
is-open="vm.endDateOpened"
datepicker-options="vm.datePickerOptions"
min-date="vm.dateFilter.startDate"
max-date="vm.currentDate"
show-button-bar="false"
close-text="Close" />

然后在 Controller 中

vm.datePickerOptions = {
altInputFormats: ['M!/d!/yyyy'],
// rest of options ...
}

关于angularjs - ui bootstrap datepicker替代日期格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36177133/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com