Skip to content

Commit d34be3e

Browse files
committed
Add time-ago pipe
1 parent 2b5b822 commit d34be3e

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

package-lock.json

Lines changed: 29 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@angular/router": "~7.2.0",
2222
"core-js": "^2.5.4",
2323
"rxjs": "~6.3.3",
24+
"time-ago-pipe": "^1.3.2",
2425
"tslib": "^1.9.0",
2526
"zone.js": "~0.8.26"
2627
},

src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { BrowserModule } from '@angular/platform-browser';
22
import { NgModule } from '@angular/core';
3+
import { TimeAgoPipe } from 'time-ago-pipe';
34

45
import { AppRoutingModule } from './app-routing.module';
56
import { AppComponent } from './app.component';
@@ -8,7 +9,8 @@ import { TimelineComponent } from './timeline/timeline.component';
89
@NgModule({
910
declarations: [
1011
AppComponent,
11-
TimelineComponent
12+
TimelineComponent,
13+
TimeAgoPipe
1214
],
1315
imports: [
1416
BrowserModule,

src/app/timeline/timeline.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div *ngFor="let tweet of tweets" class="tweet-container">
22
<div class="tweet-header">
33
<strong>{{ tweet.user }}</strong>
4-
<small class="time">{{ tweet.created_at | date:'short' }}</small>
4+
<small class="time">{{ tweet.created_at | timeAgo }}</small>
55
</div>
66
<div class="tweet-content">
77
{{ tweet.text }}

0 commit comments

Comments
 (0)