问题
Hi I am trying to compare today's date with ng-repeat date field using momentJS
here is my html code
<span class="time-stamp float-right" ng-if="recent.createdAt | amDateFormat: 'DD/MM/YYYY' == todayDate">{{ recent.createdAt | amDateFormat: 'hh:mm A' }}</span>
<span class="time-stamp float-right" ng-if="recent.createdAt | amDateFormat: 'DD/MM/YYYY' != todayDate">{{ recent.createdAt | amDateFormat: 'DD/MM/YYYY' }}</span>
and here is today's variable I declared
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
if(day<10)
{
day = '0' + day;
}
if(month<10)
{
month = '0' + month;
}
$scope.todayDate = (day + "/" + month + "/" + year);
but when I compare it gives me error of TypeError: format.match is not a function any help please that how to compare with today's date
EDIT - {{ recent.createdAt | amDateFormat: 'DD/MM/YYYY' }} gives perfect result as 08/04/2016 like this
回答1:
Since the binding syntax is evaluating an expression: Add () to date/filter: {{ (recent.createdAt | amDateFormat: 'DD/MM/YYYY') == todayDate }}
来源:https://stackoverflow.com/questions/36513967/typeerror-format-match-is-not-a-function-in-moment-angularjs