Skip to content

Improvement: easier way to change months #10

Description

@rcluan

Hello there, I've notice that changing the months is a bit annoying. You've got to select the month and then the year to get the correct date. To avoid this I did a nextDate() and previousDate(), so feel free to add it to the project. Worth saying I'm using moment.js to increment and decrement the month, but I think this can be easily changed.

this.nextDate = function() {

    var date = this.tempDate;
    var nextDate = moment(date).add(1, 'month');

    this.selectMonth(nextDate._d.getMonth());
    this.selectYear(nextDate._d.getFullYear());
}

this.previousDate = function() {

    var date = this.tempDate;
    var previousDate = moment(date).subtract(1, 'month');

    this.selectMonth(previousDate._d.getMonth());
    this.selectYear(previousDate._d.getFullYear());
}

I also changed the template in a way the Month and Year labels are between an arrow-left icon and an arrow-right icon:

`






{{datepickerCtrl.getTempMonth()}} {{datepickerCtrl.tempDate | date: 'yyyy'}}



`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions