gpt4 book ai didi

AngularJS : tomorrow's date and yesterday's date with some ng component

转载 作者:行者123 更新时间:2023-12-03 07:18:46 24 4
gpt4 key购买 nike

$scope.date = new Date();   
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);

我写过这样的东西,我知道它不正确。请纠正我以这种格式显示它 {{date |日期:'EEE,dd MMM yyyy'}}

编辑 1: 我希望在单击右箭头按钮时显示明天的日期,在单击左箭头按钮时显示昨天的日期,其中单击的位置与 2014 年 9 月 3 日星期三相同。隐藏/显示功能,如何编码,我不明白如何使用 Angular 来获取它。引用图片 https://www.google.co.in/search?q=full+calendar+day+view&source=lnms&tbm=isch&sa=X&ei=PIqjVbP4FIijugS3qYOgBg&ved=0CAcQ_AUoAQ&biw=1360&bih=595#imgrc=2E7vtXzvWMYS0M%3A

最佳答案

也许你想要这样的东西?

JSFiddle

HTML:

<div ng-app="myApp" ng-controller="myCtrl">
<p><a href="" ng-click="showToday = true; showTomorrow = false">Left arrow</a></p>
<p><a href="" ng-click="showTomorrow = true; showToday = false">Right arrow</a></p>
<span ng-show="showToday">Today: {{date | date:'EEE, dd MMM yyyy'}}</span>
<span ng-show="showTomorrow">Tomorrow: {{tomorrow | date:'EEE, dd MMM yyyy'}}</span>
</div>

JS:

angular.module('myApp', [])
.controller('myCtrl', function ($scope) {
$scope.showToday = false;
$scope.showTomorrow = false;
$scope.date = new Date();
$scope.tomorrow = new Date();
$scope.tomorrow.setDate($scope.tomorrow.getDate() + 1);
});

关于AngularJS : tomorrow's date and yesterday's date with some ng component,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31378925/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com