javascript angularjs datepicker 动态设置最大日期和最小日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28382891/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
angularjs datepicker to set max date and min date dynamically
提问by Milind
I am using below date-picker plugin for angularjs which is made from pickadate.js https://github.com/alongubkin/angular-datepicker
我正在为 angularjs 使用下面的日期选择器插件,它是由 pickadate.js https://github.com/alongubkin/angular-datepicker
I am using this plugin twice on the page. Plugin have very good option max date and min date which will help us select between those date.
我在页面上使用了这个插件两次。插件有很好的选项最大日期和最小日期,这将帮助我们在这些日期之间进行选择。
Example options
示例选项
$scope.depOptions = {
format: 'dd/mm/yyyy',
min: minDate,
max: maxDate,
onClose: function(){
$scope.arrOptions.min = $scope.depDate;
}
}
Now I want to make min date starting from selected. I tried $watch and also tried to onClose method provided by plugin but I could not do it. Kindly somebody help me.
现在我想从选定开始制作最小日期。我试过 $watch 也试过插件提供的 onClose 方法,但我做不到。请有人帮助我。
采纳答案by Aneesh Kallarakkal
It seems that the element's configuration once initialized cannot be changed. Try putting the arrival input in ngIf, so that it is always rendered anew when departure changes.
似乎元素的配置一旦初始化就无法更改。尝试将到达输入放在 ngIf 中,以便在出发更改时始终重新呈现它。