I am currently working on a project that utilizes AngularJS and Ionic frameworks. The main feature of the project will involve users inputting data to create a list, and allowing any user to comment on each item in the list.
One challenge I have encountered is how to include a timestamp for when a user adds an item to the list or comments on it.
After some research, I discovered that AngularJS has a built-in method called "[ ].created" which can be used for this purpose. However, when I attempted to implement it without using controllers, it did not work as expected. I then tried adding JavaScript code, but that also failed. Here is the code snippet:
I am unsure if this issue could be related to compatibility with Ionic. Any assistance would be greatly appreciated, especially if I can stick to using the AngularJS method. Thank you!
Refer to the AngularJS documentation for more information on dates
Below is the resultant code with added filter:
HTML section (including ng-controller="MainCtrl")
<div class="post row" ng-repeat="post in posts"></div>
<a href="{{ post.url }}">{{ post.title }}
<span class="url">({{ post.url | hostnameFromUrl }})</span>
</a>
<br> {{ post.created | date }}
<!-- This is the added AngularJS code -->