Angularjs,如何在cshtml中显示DateTime [英] Angularjs, how to display DateTime in cshtml
本文介绍了Angularjs,如何在cshtml中显示DateTime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了一段代码,从db获取记录列表,并将它们放在$ scope.records中。
I wrote a piece of code for getting a list of record from db and put them in $scope.records.
var app = angular.module('MyApp', []);
app.controller('MyAppController', ['$scope', '$http', function ($scope, $http) {
$http({ method: 'GET', url: '/Api/GetRecord' }).
success(function (data, status, headers, config) {
$scope.records = data;
}).
error(function (data, status, headers, config) {
alert(data);
});
}]);
然后,我想显示如下所示的记录。
Then, I want to display the records like below.
<div ng-repeat="record in records">
<div>{{record.ID}}</div>
<div>{{record.SubmitDate}}</div>
<div>{{record.Status}}</div>
</div>
正确显示ID和状态。但是,提交日期不能显示。提交日期为db,但所有提交日期为/ Date(1472522357080)/,同时显示在网站中。
The ID and status are shown correctly. However, the submit dates cannot show probably.The submit date is "2016-08-30 09:59:17.080" in db but all the submit dates become "/Date(1472522357080)/" while displaying in the website.
如何正确显示日期时间?谢谢。
How can I display the datetime correctly? Thanks.
推荐答案
尝试使用日期过滤器
{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}
或
{{record.SubmitDate.replace('/Date(','').replace(')/','') | date:'yyyy-MM-dd HH:mm:ss Z'}}
这篇关于Angularjs,如何在cshtml中显示DateTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文