Issue
Today I found that's it's not working to convert for a date inside angular expression.
So I just making something like
<th>{{new Date(elem.timestamp}}</th>
But it fails with internal angular error.
So why it's not possible to cast to Date inside angular expression?
Solution
Because angular expressions do not accept arbitrary Javascript code, including creating new objects. What you are looking for is called angular filters, they were specifically designed for this case.
So instead of
{{new Date(elem.timestamp)}}
you should write
{{elem.timestamp | date: 'yyyy-MM-dd'}}
More info on the date filter can be found here. More on filters, in general, can be found here.
Answered By - package
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.