AngularJs NG-如果比较日期 [英] AngularJs ng-if comparing dates
本文介绍了AngularJs NG-如果比较日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我期待两个日期中比较NG-如果这是我的玉文件的样子。
I am looking to compare two dates in ng-if this is what my jade file looks like.
li.list-group-item(ng-if="app.Segments[0].StartDate.getTime() > date.getTime()")
div.row
div.col-xs-12
span
i.fa.fa-plus-square
这code将一个LI希望添加到我的UI如果第一个段的开始日期是今天之后。
This code will hopefully add an li to my ui if the startdate of the first segment is after today.
$scope.date = new Date();
$scope.app = {
Segments: [{
StartDate: 2014-11-15T04:00:00.000Z
EndDate: 2014-11-20T04:00:00.000Z
},
{
StartDate: 2014-11-21T04:00:00.000Z
EndDate: 2014-11-25T04:00:00.000Z
}]
}
反正有使这项工作?
Is there anyway to make this work?
推荐答案
如果他们约会的对象只是直接对它们进行比较,而不 .getTime()
If they're date object just compare them directly without .getTime()
$scope.date2005 = new Date('2005/01/01');
$scope.date2006 = new Date('2006-01-01T04:00:00.000Z');
<div ng-if="date2005 > date2006">date2005 > date2006</div> <!-- won't show -->
<div ng-if="date2006 > date2005">date2006 > date2005</div> <!-- will show -->
<一个href=\"http://plnkr.co/edit/fNB11U6KmFszdV3lMAPJ?p=$p$pview\">http://plnkr.co/edit/fNB11U6KmFszdV3lMAPJ?p=$p$pview
这篇关于AngularJs NG-如果比较日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文