Add a <time-ago> component to abstract out common handling of showing how long ago an event occurred
This commit is contained in:
parent
b9768ef6cf
commit
33af54d355
3 changed files with 21 additions and 0 deletions
6
static/js/directives/ui/time-ago/time-ago.component.html
Normal file
6
static/js/directives/ui/time-ago/time-ago.component.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<span>
|
||||
<span ng-if="::$ctrl.datetime" data-title="{{ ::$ctrl.datetime | amDateFormat:'dddd, MMMM Do YYYY, h:mm:ss a' }}" bs-tooltip>
|
||||
<span am-time-ago="::$ctrl.datetime"></span>
|
||||
</span>
|
||||
<span ng-if="::!$ctrl.datetime">Unknown</span>
|
||||
</span>
|
13
static/js/directives/ui/time-ago/time-ago.component.ts
Normal file
13
static/js/directives/ui/time-ago/time-ago.component.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { Input, Component } from 'ng-metadata/core';
|
||||
|
||||
/**
|
||||
* A component that displays how long ago an event occurred, with associated
|
||||
* tooltip showing the actual time.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'timeAgo',
|
||||
templateUrl: '/static/js/directives/ui/time-ago/time-ago.component.html'
|
||||
})
|
||||
export class TimeAgoComponent {
|
||||
@Input('<') public datetime: any;
|
||||
}
|
Reference in a new issue