AngularJS:明天的日期和昨天的日期,带有某些ng组件 [英] AngularJS : tomorrow's date and yesterday's date with some ng component
问题描述
$scope.date = new Date();
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
我写了这样的东西,我知道它是不正确的.请更正我,使其以{{date | date:'EEE, dd MMM yyyy'}}
I have written something like this, and I know its not correct. Please correct me to display it in this format {{date | date:'EEE, dd MMM yyyy'}}
我希望在单击向右箭头按钮时显示明天的日期,并在昨天向左箭头按钮中显示的日期与2014年9月3日星期三相同.如何编码,我不明白如何使用angular来获取代码.参考图片
Edit 1: I want the tomorrow's date to be displayed on click of right arrow button and yesterday on left arrow button click at same position where Wed, Sept 3, 2014. Hide/show feature, how to code, I don't understand how to get it using angular. Reference image 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
推荐答案
也许您想要这样的东西?
Probably you want something like this?
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:明天的日期和昨天的日期,带有某些ng组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!