twinssbc / AngularJS-ResponsiveCalendar

A pure AngularJS responsive calendar directive
http://twinssbc.github.io/AngularJS-ResponsiveCalendar/demo/
MIT License
112 stars 77 forks source link

How do I create more than one calendar and link them together? #60

Open isteven opened 8 years ago

isteven commented 8 years ago

Hi,

I need to create two calendars, showing current month & current month + 1 (for example, september and october 2015).

These calendar would be linked together; if I click the "Next" button on one calendar, the other one will also advance to the next month, like:

Calendar 1: September 2016 Calendar 2: October 2016

I click "Next" on calendar 1, then they'll be:

Calendar 1: October 2016 Calendar 2: November 2016

What is the best way to do this?

Thanks.

twinssbc commented 8 years ago

@isteven You can control the calendar navigation by changing the ng-model variable. Let's say the first calendar is bound to currentDate, the second calendar is bound to currentDate2. Then in the rangeChanged callback of first calendar, you can do something like:

    $scope.rangeChanged = function (startTime, endTime) {
        var time = new Date($scope.currentDate);
        time.setMonth($scope.currentDate.getMonth() +1);
        $scope.currentDate2 = time;
    };