简体   繁体   English

AngularJs输入周-显示当前CalendarWeek /将10天添加到当前日历周

[英]AngularJs input Week - Show current CalendarWeek / Add 10 days to Current Calender Week

I am quite new to Angular and facing some problems atm. 我对Angular并不陌生,并且遇到了一些atm问题。

Here is what I want to build: 这是我要构建的:

  1. I want to show the current Date: yyyy-MM-ss (Works) 我想显示当前日期:yyyy-MM-ss (Works)
  2. I want to show the current Calendar Week: yyyy-Www (Doesn't Work) 我想显示当前的日历周:yyyy-Www (无效)
  3. On button ng-click, I want to add 10 days to todays date. 在按钮ng-click上,我想将10天添加到今天。 (Works only for 1) (仅适用于1个)

CODE: JSFiddle 编码: JSFiddle

HTML 的HTML

<div ng-controller="MyCtrl">
<div>
    DateToday<br>
    <input type="date" placeholder="yyyy-MM-dd" value="{{today | date :'yyyy-MM-dd'}}"><br><br>

    CalendarWeek:<br>
    <input type="week" placeholder="YYYY-W##" value="{{today | date :'yyyy-Www'}}"/><br><br>

    <input ng-click="add10Days()" value="Add 10 Days" type="button"/>
  </div>
</div>

JS/AngularJS: JS / AngularJS:

var myApp = angular.module('myApp',[]);

function MyCtrl($scope) {

$scope.today = new Date();

$scope.add10Days = function () {
      var numberOfDaysToAdd = 10;
      $scope.today.setDate($scope.today.getDate() + numberOfDaysToAdd);
  }; 
});

I think it has something todo with the week format yyyy-w## or maybe with the browser (Chrome) I am using. 我认为这与周格式yyyy-w ##或我正在使用的浏览器(Chrome)有关。 Help would be much appreciated :) 帮助将不胜感激:)

Thanks 谢谢

  1. 'ww' date filter only works in Angular 1.3 and on. “ ww”日期过滤器仅适用于Angular 1.3及更高版本。 I see you're on 1.0.1 我看你在1.0.1
  2. Seems to work fine in the fiddle. 似乎在小提琴中工作正常。 GIF below: GIF如下:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM