javascript - Datepicker on AngularJS error with values -
What I'm trying to do here is when a user StartDate and End date When he clicks on the previous arrow, he should get the data 7 days in advance to see the progress. Javascript : HTML : Do not we all like Javascript date? ;) In line Edit : If you can add other libraries, look at
$ scope.getDiffPrev = function (startup, endadet, compute def) {var start = startDate; Var date1 = (start.getDate (-7); Var month1 = (start.getMonth () + 1); Var year1 = start.getFullYear (); Var end = endDate; Var date2 = (end.getDate () -7); Var month2 = (end.getMonth () + 1); Var year2 = end.getFullYear (); $ http.get ('/ admin / api / stats? start =' + date1 + '-' + 1 month '-' + 1 year '& amp; end =' +2 date + + '-' +2 months + + '-' + 2 + 'and computeDiff = true'). Success (work) {$ scope.stats = data;}); }
& lt; Label & gt; From & lt; / Label & gt; & Lt; Input type = "text" datespeak-popup = "DD-MM-yay" ng-model = "start date" /> & Lt; Label & gt; / Labels & gt; & Lt; & Lt; Input type = "text" datepicker-popup = "dd-MM-yyyy" ng-model = "endDate" /> & Lt; Button class = "BTN BTN-Success" ng-click = "leaddiffprrave (startdate, endadet, compudiff)" & gt; & Larr; & Lt; / Button & gt;
var start = angular.copy (start date) start.setDate (start.getDate () + computeDiff); Var date1 = start.getDate (); Var month1 = start.getMonth () + 1; // I hate them for this one- var year1 = start.getFullYear ();
start.setDate (start.getDate (+ computeDiff); We use date () 's Internal calculation to get the correct date.
moment () Enter the subtract ('day', 7) format ('yourFormatStringHere')
Comments
Post a Comment