Open Mr-Anonymous opened 8 years ago
:+1:
I found http://momentjs.com/docs/#/displaying/tonow/ but wondering how to use it with angular-moment
You can access the moment library directly and use that functions. I think.
Hopefully this is of some use. I haven't used angular-moment to test it out though.
yourModule.filter('amD2', function() {
var mappings = {
"0 days": "Today",
"1 day from now": "Tomorrow",
"1 day ago": "Yesterday",
};
return function(amDifferenceOutput) {
var mappedValue = mappings[amDifferenceOutput];
return mappedValue || amDifferenceOutput;
}
});
Usage:
<span ng-bind="myTime | amDifference | amD2"></span>
In my app, I have to show a to-do list where the lists are saved in date format like “2016-02-06” (YYYY-MM-DD) in sql. When I show those data in the angular front-end, I want the days to be listed as:
I tried the following:
1)
am-time-ago
directive: This is not what I want since it shows in hours ago for today, etc..2)
amDifference
filter: This sorta works but still today is listed as 0 and days like 'yesterday' cannot be listed. Also I would prefer to show tomorrow instead of 1 day from now.Is there a way to achieve this with angular-moment?