0
안녕하세요, 날짜를 빼는 간단한 함수를 만들었지 만 오류가 계속 발생합니다.날짜 빼기 오류 (보간 할 수 없음)
코드 JS :
$scope.tosum = function(d1, d2) {
var d3 = new Date(d1.getTime() - d2.getTime());
console.log(d3);
return d3;
};
콘솔 오류 :
Error: [$interpolate:interr] Can't interpolate:
{{tosum(timesheet.startDate,timesheet.endDate)}}
TypeError: undefined is not a function
보기/html로 사이트 :이에 '잘못된 날짜'를 제공합니다 나는 또한 .getTime없이 시도
<tr data-ng-repeat="timesheet in timesheetsCtrl.timesheets | filter:searchText">
<td>{{tosum(timesheet.startDate,timesheet.endDate)}}</td>
콘솔
'd1'과'd2'를 로그하면, 그것들은 올바르게 정의 된 날짜이고 다른 유형의 객체가 아닌 것이 확실합니까? – mgilson
timesheet.startDate에 무엇이 들어 있습니까? –
console.log ('d1 :'+ d1 + '- d2 :'+ d2); 출력 : D1 : 2015-02-02T23 : 00 : 00.000Z - D2 : 2015-02-04T15 : 16 : UI에 MongoDB를 – Stweet