上一页 - 下周在angular.js上

时间:2014-04-23 09:42:08

标签: angularjs

我试图实施上一个 - 下周的统计数据,这将根据日期选择器的StartDate和EndDate值更改网址,但会显示一周的统计信息(例如从11-11-13 18-11- 13等等)。 有什么建议或想法吗?

1 个答案:

答案 0 :(得分:0)

我知道这已经过时了,但是如果有人发现它正在寻找答案,那么就是一个。

我不知道你的代码结构,所以我假设你有一个像这样的结构/方法的控制器:

// 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;
};

同样,在不知道如何构建控制器的情况下,很难给出确切的实现。 iterateDate函数应该按照您的要求执行。

感谢@AnthonyWJones的日期更改功能。

相关问题