我使用 API 呈现了以下数据,其中 0 类似于 {{x.count}},今天、明天和随后的日子来自 API 的 {{x.day}}。
今天有 0 次预约
明天有 0 个约会
周三有 0 次约会
周四有 0 次约会
周五有 0 次约会
我的 HTML View 如下所示:
<span ng-repeat="x in scheduledAppointments_report"><a ng-click="test(x.day);">{{x.count}} Appoinments {{x.day}}</a> <br/><br/></span>
我想检索各个超链接点击的日期。
请告诉我解决方案。
谢谢
最佳答案
尝试如下:
<div ng-app>
<div ng-controller="MyApp">
<a href="#" ng-click="get_x_day_date(0)">Today</a>
<a href="#" ng-click="get_x_day_date(1)">Tomorrow</a>
</div>
</div>
代码:
function MyApp($scope) {
$scope.today = new Date();
$scope.get_x_day_date = function(index) {
$scope.x_day = new Date();
$scope.x_day.setDate($scope.today.getDate() + index);
alert($scope.x_day);
return $scope.x_day;
}
}
关于javascript - 如何在点击时检索当前日期和后续日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43840479/