Correctly format ASP.NET MVC dates for AngularJS

前端 未结 4 1531
灰色年华
灰色年华 2021-01-05 23:51

I am using AngularJS to get data from an ASP.NET server application and display it on the client side. Here is what I\'m getting:



        
4条回答
  •  孤城傲影
    2021-01-06 00:14

    You should probably have a look at

    http://docs.angularjs.org/api/ng.filter:date

    It gives you all the necessary tools to modify and display Date in the format you want.

    EDIT :

    Could you modify your server to not send the date as Date(****) but just the **** is fine... If you send the date as Date(****), then you are left with 2 options both of which arent good.

    1. TO eval the Date. NO eval.. its not good for your health.
    2. Strip out the Date using a combination of regex.. Again, its possible.. but not recommended.

    why send it in and strip it out? Why not just take it out of the server side itself?

提交回复
热议问题