How to add Days through AngularJS Date Filter?

前端 未结 2 1865
轻奢々
轻奢々 2021-01-20 06:08

I have this code:


  

Empty Angular App

{{\"2015-07-08T15:10:
2条回答
  •  没有蜡笔的小新
    2021-01-20 06:26

    As you told, use javascript is better option.

    var app = angular.module('my-app', []);
    
    app.controller("my-controller", function($scope) {
      $scope.name = "world";
      $scope.mydate = new Date("2015-07-08T15:10:10.530Z");
    
      var numberOfDaysToAdd = 46;
      $scope.newdate = $scope.mydate.setDate($scope.mydate.getDate() + numberOfDaysToAdd); 
    
    });
    

    http://codepen.io/anon/pen/MwVNpq

提交回复
热议问题