TypeError:format.match 不是 moment angularJS 中的函数 [英] TypeError: format.match is not a function in moment angularJS

查看:41
本文介绍了TypeError:format.match 不是 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>

这是我今天声明的变量

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 is not a function 请帮助说明如何与今天的日期进行比较

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

编辑 - {{最近的.createdAt |amDateFormat: 'DD/MM/YYYY' }} 像这样 08/04/2016 给出完美的结果

EDIT - {{ recent.createdAt | amDateFormat: 'DD/MM/YYYY' }} gives perfect result as 08/04/2016 like this

推荐答案

由于绑定语法是对表达式求值: Add () to date/filter:{{ (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 不是 moment angularJS 中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆