0

Hi i made a simple function to subtract dates, but i keeps giving me an error.

Code JS:

        $scope.tosum = function(d1, d2) {

        var d3 = new Date(d1.getTime() - d2.getTime());
        console.log(d3);
        return d3;
    };

Console Error:

Error: [$interpolate:interr] Can't interpolate: 
{{tosum(timesheet.startDate,timesheet.endDate )}}
TypeError: undefined is not a function

View/ html site :

  <tr data-ng-repeat="timesheet in timesheetsCtrl.timesheets | filter:searchText">
   <td>{{tosum(timesheet.startDate,timesheet.endDate )}}</td>

I also have tried without .getTime this gives 'Invalid Date' in console

Stweet
  • 683
  • 3
  • 11
  • 26

1 Answers1

0

Are you using controllerAs?

If you aren't, just write the name of the function, otherwise you'll need to prefix the controller name.

Peter Ashwell
  • 4,292
  • 2
  • 18
  • 22
  • in same controller, changed to this.tosum = function(d1, d2) {..... {{timesheetsCtrl.tosum(timesheet.startDate,timesheet.endDate )}} but still same error – Stweet Feb 05 '15 at 08:31