我在阵列上有一个ng-repeat。
每个对象都有一个名为foreach($response->businesses as $key=>$r)
{
if($key>$limit) break;
echo $r->name //May need to do some var_dumps in order to see what you get
}
的属性,它只是"checkdate"
。
我希望"New Date()"
仅显示今天创建的对象。我怎么能这样做?
由于
答案 0 :(得分:1)
$scope.list1 = [
{name: "item1", checkdate: '2016-03-04T09:25:57.882Z'},
{name: "item2", checkdate: '2016-03-05T09:25:57.882Z'},
{name: "item3", checkdate: '2016-03-06T09:25:57.882Z'}];
var curDate = new Date();
var y = curDate.getFullYear();
var m = curDate.getMonth() + 1;
if (m < 10) {
m = '0' + m;
}
var d = curDate.getDate();
if (d < 10) {
d = '0' + d;
}
$scope.curDate = y + '-' + m + '-' + d;
...
<div ng-repeat="item in list1 | filter:{checkdate: curDate}">
{{item.name}} - {{item.checkdate}}
</div>
答案 1 :(得分:0)
使用以下内容:
ng-repeat="obj in objects"
和里面:
ng-show="obj.date === Date.now()"
根据对象日期格式的格式修改Date.now()
。
赞here
或者您可以执行以下操作:
ng-show="checkDate(obj.date)"
其中
checkdate(date){
var todaysDate = new Date();
//call setHours to take the time out of the comparison
if(date.setHours(0,0,0,0) == todaysDate.setHours(0,0,0,0));
{
return true
} else { return false}
}