Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi guys.
I am binding data to ng-grid by using ajax call
every thing going well the problem is in date column
instead of showing date it show simple json object like

(/Date(1412946580771)/)


i have taken follwing approaches but nothing worked for me.
XML
cellTemplate: "<div>{{LoadDate|date:'yyyy-MM-dd'}}</div>"
cellFilter: 'date:\'MM/dd/yyyy HH:MM:SS Z\''
cellFilter: 'date:\'MM/dd/yyyy\''

Any help would be very much appreciated.
Posted

XML
<div ng:app ng:controller="Scoper">
    In: {{v.Dt}}  <br />
    Angular: {{v.Dt | date:'yyyy-MM-dd HH:mm:ss Z'}} <br />
    In: {{v.sDt}}  <br />
    Angular: {{v.sDt | date:'yyyy-MM-dd HH:mm:ss Z'}} <br />
    In: {{v.DDt}}  <br />
    Angular: {{v.DDt | date:'yyyy-MM-dd HH:mm:ss Z'}} <br />
</div>




function Scoper($scope) {
var s = "2012-10-16T17:57:28.556094Z";
$scope.v = {
Dt: Date.now(),
sDt: s,
DDt: Date.parse(s)
}
}
 
Share this answer
 
XML
<span ng-non-bindable>{{1288323623006 | date:'medium'}}</span>:
    <span>{{1288323623006 | date:'medium'}}</span><br>
<span ng-non-bindable>{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}</span>:
   <span>{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}</span><br>
<span ng-non-bindable>{{1288323623006 | date:'MM/dd/yyyy @ h:mma'}}</span>:
   <span>{{'1288323623006' | date:'MM/dd/yyyy @ h:mma'}}</span><br>
<span ng-non-bindable>{{1288323623006 | date:"MM/dd/yyyy 'at' h:mma"}}</span>:
   <span>{{'1288323623006' | date:"MM/dd/yyyy 'at' h:mma"}}</span><br>



OutPut:

C#
{{1288323623006 | date:'medium'}}: Oct 29, 2010 9:10:23 AM
{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}: 2010-10-29 09:10:23 +0530
{{1288323623006 | date:'MM/dd/yyyy @ h:mma'}}: 10/29/2010 @ 9:10AM
{{1288323623006 | date:"MM/dd/yyyy 'at' h:mma"}}: 10/29/2010 at 9:10AM
 
Share this answer
 
Comments
C For Code!!! 10-Oct-14 9:37am    
I had tried this one also forgot to mention. This one also not working :(
C For Code!!! 10-Oct-14 9:39am    
you can easily make out the difference in date object return in my case by json result and date object used in above example.
Kamal Surani 10-Oct-14 9:46am    
your date is which format return json result
first convert date in int format that than try.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900