我了解当前日期和时间是从new Date.getTime()
如何实现它,以便所有用户的每个新帖子都将被标记日期和时间并与帖子内容一起保存?
是var timestamp = new Date.getTime()
还是$scope.timestamp = new Date.getTime()
?使用 ng-click=submitPost() 提交表单时,如何在数组中保存日期?
我插入以下内容以用日期和时间标记每个条目。在提交后控制器中:
$scope.post = {url: 'http://', title: '', timestamp: new Date()};
并在 html
{{post.timestamp}}
对条目的时间戳注释更新:
$scope.addComment = function () {
var comment = {
text: $scope.commentText,
creator: $scope.user.profile.username,
creatorUID: $scope.user.uid,
timestamp: new Date().toUTCString() //I added it here but doesnt work
};
$scope.comments.$add(comment);
$scope.commentText = '';
};