a small angular2 component for displaying how long ago from now.
use npm:
npm install ng2-timeago --save
The time you want to be transformed.
default true. set to 'false' if you don't want to live update.
Live update interval. Default 60*1000(1 minute).
If time longer than maxPerid, it will show a special date format you setted via afterMaxDateFormat
.
Defalut 365 * 24 * 60 * 60 * 1000(1 year).
Default 'medium', for more supported date format, see datePipe in angular2 doc.
default 'ago', time ago suffix, you can use other words, eg: 'from now'.
import {TimeAgo} from 'ng2-timeago/timeago'
@Component({
selector: 'foo',
template: `<time-ago [time]="time" [maxPeriod]="30*24*60*60"> `,
directives: [TimeAgo]
})
class Foo {
time: Date = new Date(Date.now() - 5 * 24 * 60 * 60 * 1000)
}
Complete the test case.