Hey there, I created a basic function to subtract dates in JavaScript, but I keep getting an error.
Here is the JS code:
$scope.tosum = function(d1, d2) {
var d3 = new Date(d1.getTime() - d2.getTime());
console.log(d3);
return d3;
};
This is the error message displayed in the console:
Error: [$interpolate:interr] Can't interpolate:
{{tosum(timesheet.startDate,timesheet.endDate )}}
TypeError: undefined is not a function
Below is the snippet from the HTML view:
<tr data-ng-repeat="timesheet in timesheetsCtrl.timesheets | filter:searchText">
<td>{{tosum(timesheet.startDate,timesheet.endDate )}}</td>
I have also attempted removing .getTime, which results in 'Invalid Date' being shown in the console.