[英]Angular UI Bootstrap Datepicker - show specific date on Calendar open
I am using Angular UI Bootstrap dirrective for Datepicker. 我正在为Datepicker使用Angular UI Bootstrap dirrective。 I have list of dates, that I set in calendar as active (ie other dates are disabled).
我有在日历中设置为有效的日期列表(即其他日期已禁用)。
Here is my date list - ["10/16/2015", "11/20/2015", "12/18/2015"]
这是我的约会清单-
["10/16/2015", "11/20/2015", "12/18/2015"]
UI Datepicker always open current date/month. UI Datepicker始终打开当前日期/月份。 How can I make, so calendar would open on specific date, even if this date is from previous year?
我该如何制作日历,即使该日期是前一年的日历也可以在特定日期打开?
I found option defaultViewDate option, but it seems that it doesn't work (at least I didn't find this method in tpl library) 我找到了defaultDefaultDate选项,但似乎不起作用(至少我没有在tpl库中找到此方法)
Any ideas how I can make that? 有什么想法可以做到吗?
Thanks! 谢谢!
Given Angular UI's documentation on its datepicker, the calendar adapts to a date set on the ng-model , so all you'd have to do is create a date: 鉴于Angular UI的datepicker 文档 ,日历会适应ng-model上设置的日期,因此您要做的就是创建一个日期:
new Date(year, month, day, hours, minutes, seconds, milliseconds);
See w3schools for more on that. 有关更多信息,请参见w3schools 。
Set the model to that and you should be good to go. 为此设置模型,您应该一切顺利。 Let us know if it works.
让我们知道它是否有效。
EDIT: 编辑:
To set the initial date when no date is specified, use init-date by creating a default date on the scope of the parent controller. 要在未指定日期的情况下设置初始日期,请通过在父控制器的范围内创建默认日期来使用init-date 。
angular.module("yourModule").controller("parentCtrl", function($scope) {
$scope.initialDate = new Date(2000, 5, 4);
}
And the HTML: 和HTML:
<div ng-controller="parentCtrl">
<datepicker init-date="initialDate"></datepicker>
</div>
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.