如果用户从日历更改日期并将此更新日期传递给主控制器,我希望能够访问该事件。
我的代码如下
$scope.cb= function(start, end){
$('#dateRange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
startDateCal = start;
endDateCal = end;
if($('#sel_deviceType').length){
type = $('#sel_deviceType').val();
} else {
type = "A";
}
$scope.loadChart(parseInt(start/1000),parseInt(end/1000), appKey, type);
}
$scope.cb($rootScope.startDateCal,$rootScope.endDateCal);
// $scope.cb(moment().subtract(93, 'days'), moment());
$('#dateRange').daterangepicker({
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'This Week': [moment().startOf('week'), moment().endOf('week')],
'Last Week': [moment().subtract(1, 'week').startOf('week'), moment().subtract(1, 'week').endOf('week')],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
locale: {
format: 'YYYY-MM-DD',
applyLabel: "Select"
},
startDate: $rootScope.startDateCal,
endDate: $rootScope.endDateCal
}, $scope.cb);
<div id="dateRange">