当人们按下重设按钮时,我想重设日期。今天和30天前。以下代码的结果是设置了日期范围的值,但是UI不会更新。
$scope.backThirtyDays = function () {
return moment().subtract(30, 'days').endOf('day');
};
$scope.reset = function () {
$scope.datePicker = {
date: {
startDate: $scope.backThirtyDays(),
endDate: $scope.yesterday()
}
};
用html定义的模型
<label class="col-sm-3 control-label" for="date-range-picker-input">Transaction Date Range</label>
<div class="col-sm-3">
<input class="form-control" date-range-picker
id="date-range-picker-input"
name="datePicker.date"
class="form-control date-picker"
type="text"
ng-model="datePicker.date"
options="datePickerMax.opts"/>
</div>
daterangepicker代码中有一只手表
$scope.$watch('model.startDate', function(n) {
return _setStartDate(n);
});
angular-daterangepicker-18个月大 AngularJS v1.5.8