I am learning a bit of .NET and handlebars
, need some help figuring out how to deal with JSON
date parsing in this case:
Method in my controller
public JsonResult stats()
{
IQueryable<EnrollmentDateGroup> data = from student in db.Students
group student by student.EnrollmentDate into dateGroup
select new EnrollmentDateGroup()
{
EnrollmentDate = dateGroup.Key,
StudentCount = dateGroup.Count()
};
return Json(data.ToList());
}
Template using handlebars
<script id="mytemplate" type="text/x-handlebars-template">
<h3 style="margin-top:20px">Student Body Statistics</h3>
<table>
<tr>
<th>Enrollment Date</th>
<th>Students</th>
</tr>
{{#each this}}
<tr>
<td>{{{EnrollmentDate}}}</td>
<td>{{{StudentCount}}}</td>
</tr>
{{/each}}
</table>
</script>
JavaScript
<script type="text/javascript">
(function () {
var templateHtml = $("#mytemplate").html();
var sourceHtml = Handlebars.compile(templateHtml);
$.post("@Url.Action("stats")", "", function (data) {
$('#stu').html(sourceHtml(data));
console.log(data);
}, "json");
})();
</script>
and my result coming from DB
into data is a list of /Date(1125547200000)/
How can I parse this date to real date?