Angular ui bootstrap 当前日期(今天)突出显示而不选择 [英] Angular ui bootstrap current date (today) highlight without selecting
问题描述
我正在使用 Angular.UI Bootstrap Datepicker (http://angular-ui.github.io/bootstrap/#/datepicker)
I am using Angular.UI Bootstrap Datepicker (http://angular-ui.github.io/bootstrap/#/datepicker)
现在我正在挑战一个问题:客户总是希望看到当前日期突出显示,即使它没有被选中.就像在这个例子中一样(http://angular-ui.github.io/ui-date/).
Now I am challenging one problem: the client always wants to see current date highlighted, even if it is not selected. Just like in this example (http://angular-ui.github.io/ui-date/).
试图用谷歌搜索这个问题,但没有找到 Angular.UI Bootstrap Datepicker 的解决方案.
Tried to google this problem, but no solution found for Angular.UI Bootstrap Datepicker.
没办法,切换到ui-date.有什么想法吗?
There is no way, to switch to ui-date. Any ideas?
谢谢!
推荐答案
在datepicker控件中替换这个
Replace in the datepicker control this
var days = getDates(firstDate, numDates), labels = new Array(7);
for (var i = 0; i < numDates; i++) {
var dt = new Date(days[i]);
days[i] = makeDate(dt, format.day, (selected && selected.getDate() === dt.getDate() && selected.getMonth() === dt.getMonth() && selected.getFullYear() === dt.getFullYear()), dt.getMonth() !== month);
}
与
var today = new Date();
var days = getDates(firstDate, numDates), labels = new Array(7);
for (var i = 0; i < numDates; i++) {
var dt = new Date(days[i]);
var highlight = (selected && selected.getDate() === dt.getDate() && selected.getMonth() === dt.getMonth() && selected.getFullYear() === dt.getFullYear());
if(!highlight) {
highlight = (today.getDate() === dt.getDate() && today.getMonth() === dt.getMonth() && today.getFullYear() === dt.getFullYear());
}
days[i] = makeDate(dt, format.day, highlight, dt.getMonth() !== month);
}
这篇关于Angular ui bootstrap 当前日期(今天)突出显示而不选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!