【发布时间】:2016-01-07 12:24:59
【问题描述】:
我正在使用 Angular UI bootstrap 的 datepicker ,当我以编程方式更改日期时,视图不会改变,当我在 11 月 30 日并且我以编程方式将日期更改为 12 月 2 日时,日期更改但视图在 11 月仍然固定,这是我编写下一个日期按钮的方法。
$scope.right=function(){
if($scope.viewmodel.timeResolution=='yearly')
$scope.dt.setFullYear($scope.dt.getFullYear()+1);
else if($scope.viewmodel.timeResolution=='monthly')
$scope.dt.setMonth($scope.dt.getMonth()+1);
else if($scope.viewmodel.timeResolution=='daily') {
$scope.dt.setDate($scope.dt.getDate() + 1);
}
$scope.changedValue();
};
HTML:
<uib-datepicker ng-model="dt" id="dp" datepicker-mode="mode" init-date="initDate" show-weeks=false max-mode="maxMode" min-date="minDate" max-date="maxDate" min-mode="minMode" class="well well-sm" ng-change="changedValue(viewmodel.dt)"></uib-datepicker>
如何在每次在日期选择器上以编程方式更改日期时模拟刷新视图?
【问题讨论】:
-
可以添加datepicker的html代码吗?
-
@azelix 是否有添加日期的业务规则?你想禁用周末吗?
-
@JoaozitoPolo 我添加了它
标签: javascript angularjs twitter-bootstrap datepicker