Reputation: 279
is any chance to format date in ng-repeat? I was trying to format it like
<div class="col-date">{{row.Calendar.start | date : "dd.MM.y"}}</div>
But it was not working. How do I format date in ng-repeat?
Upvotes: 0
Views: 98
Reputation: 46
try this it worked for me hope for you to
{{row.Calendar.start | date:'MMM-dd-yyyy'}}
Upvotes: 0
Reputation: 3797
Use moment and angular-moment, are definitely best modules out there for stuff related to dates.
First of all convert $scope.row.Calendar.start to date/moment object if it is a string and then use angular moment to show desired date format
Here is a how you can do so:
Inside controller:
$scope.row.Calendar.start = moment($scope.row.Calendar.start,'YYYY-MM-DD HH:mm:ss');
<div class="col-date">{{row.Calendar.start | amDateFormat : "dd.MM.y"}}
Upvotes: 1
Reputation: 1585
It seems like you are trying to apply angular date filter of a string object.
Try to first convert it to a Date object in controller and then apply date filter on it.
EXAMPLE
$scope.dtObj = new Date($scope.row.Calendar.start);
then in HTML write this
<div class="col-date">{{dtObj | date : "dd.MM.y"}}</div>
for more details check out documentation here https://docs.angularjs.org/api/ng/filter/date
Upvotes: 0
Reputation: 61
From AngularJS perspective everything seems to be valid.
Please check following:
Please provide us with more information about what are you trying to convert, and what result do you have
Upvotes: 0