TypeError:format.match不是angularJS中的函数 [英] TypeError: format.match is not a function in moment angularJS
问题描述
我正在尝试使用momentJS将今天的日期与ng-repeat日期字段进行比较
Hi I am trying to compare today's date with ng-repeat date field using momentJS
这是我的html代码
<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);
但是当我比较它会给我TypeError错误:format.match不是一个函数,请问如何与今天的日期进行比较
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
编辑-{{ amDateFormat:'DD/MM/YYYY'}}像这样在2016年4月4日给出了完美的结果
EDIT - {{ recent.createdAt | amDateFormat: 'DD/MM/YYYY' }} gives perfect result as 08/04/2016 like this
推荐答案
由于绑定语法正在评估表达式:在日期/过滤器中添加(): {{(recent.createdAt | amDateFormat:'DD/MM/YYYY')== todayDate}}
Since the binding syntax is evaluating an expression: Add () to date/filter: {{ (recent.createdAt | amDateFormat: 'DD/MM/YYYY') == todayDate }}
这篇关于TypeError:format.match不是angularJS中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!