0

I'm trying to implement a previous - next week stats which will change the url depending on StartDate and EndDate values of a datepicker but will show stats of a week (like from 11-11-13 18-11-13 and so on). Any suggestions or ideas?

Tim
  • 41,901
  • 18
  • 127
  • 145
user3531335
  • 57
  • 1
  • 1
  • 5

1 Answers1

0

I know this is old, but in case someone stubles on it looking for an answer, here is one.

I do not know your code structure, so I will assume you have a controller with a structure/method like this:

// this is tied to your HTML with ng-model (I assume)
this.currentDate = new Date();

// tie this to your "next week" button with ng-click
this.iterateDate = function() {

    var nextWeek = new Date(this.currentDate.valueOf());

    // adding/subtracting 7 for next/previous week. Can be less for your use case
    nextWeek.setDate(nextWeek.getDate() + 7);

    // update the model value (if this is your approach)
    this.currentDate = nextWeek;
};

Again, without knowing how you structured your controller it is hard to give an exact implementation. The iterateDate function should do what you ask for though.

Credit to @AnthonyWJones for his date change function.

Community
  • 1
  • 1
Mac
  • 1,143
  • 6
  • 21
  • 45