【发布时间】:2017-02-20 08:56:00
【问题描述】:
我有日期作为日期对象。
当我这样做时
$scope.test = new Date([2017,2,15]);
<pre>{{test}}</pre>
<pre>{{test.getDate()}}</pre>
我明白了
“2017-02-14T23:00:00.000Z”和 15
所以到这里为止,我们都很好。
但在我的情况下,当我尝试对另一个对象中的日期执行相同操作时,例如在此架构中:
var tachesSchema = new mongoose.Schema({
title : String,
start: {type: Date, default: new Date()},
end: {type: Date, default: new Date()},
comment : String,
state : Boolean,
projet : { type: ObjectId, ref: 'Projets' }
});
我什么都没得到:(
这段代码:
{{tache.start}}
这样显示日期“2017-02-20T23:00:00.000Z”
但是
<pre>{{tache.start.getDate()}}</pre>
什么都不显示。
我错过了什么?
编辑
我没有明确指出我想在 ng-repeat 中执行此操作
下面的代码给了我像“2017-02-20T23:00:00.000Z”这样的日期
<pre ng-repeat="tache in taches">
{{tache.start}}
</pre>
下面的代码什么也没给我
<pre ng-repeat="tache in taches">
{{tache.start.getDay()}}
</pre>
【问题讨论】:
标签: javascript angularjs date object