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?
            Asked
            
        
        
            Active
            
        
            Viewed 258 times
        
    0
            
            
        - 
                    1And the problem is ...? – VahidNaderi Apr 23 '14 at 09:47
- 
                    I'm just asking for suggestions and ideas on how to do it – user3531335 Apr 23 '14 at 09:48
1 Answers
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.
 
     
     
    