Skip to content

Commit 65b2a42

Browse files
committed
Add time ago for the review date
1 parent ea1a78d commit 65b2a42

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

itenium-socks/package-lock.json

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

itenium-socks/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@angular/router": "^18.0.0",
2121
"@fortawesome/angular-fontawesome": "^0.15.0",
2222
"@fortawesome/fontawesome-free": "^6.5.2",
23+
"ngx-timeago": "^3.0.0",
2324
"rxjs": "~7.8.0",
2425
"tslib": "^2.3.0",
2526
"zone.js": "~0.14.3"
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import { ApplicationConfig, DEFAULT_CURRENCY_CODE, provideZoneChangeDetection } from '@angular/core';
1+
import { ApplicationConfig, DEFAULT_CURRENCY_CODE, importProvidersFrom, provideZoneChangeDetection } from '@angular/core';
22
import { provideRouter } from '@angular/router';
33
import { provideHttpClient, withFetch } from '@angular/common/http';
44

55
import { routes } from './app.routes';
6+
import { TimeagoModule } from 'ngx-timeago';
67

78
export const appConfig: ApplicationConfig = {
89
providers: [
910
provideZoneChangeDetection({ eventCoalescing: true }),
1011
provideRouter(routes),
1112
provideHttpClient(withFetch()),
12-
{provide: DEFAULT_CURRENCY_CODE, useValue: 'EUR' }
13+
{provide: DEFAULT_CURRENCY_CODE, useValue: 'EUR' },
14+
importProvidersFrom(TimeagoModule.forRoot())
1315
]
1416
};

itenium-socks/src/app/socks/sock-reviews.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ <h5>
1717
{{ review.socksId }}
1818
<i *ngFor="let _ of [].constructor(review.rating)" class="fa fa-star" style="color: gold"></i>
1919
</h5>
20-
<h6>On {{ review.added }} by {{ review.email }}</h6>
20+
<h6>On {{ review.added | timeago }} by {{ review.email }}</h6>
2121
</div>
2222
<i class="fa fa-quote-left" aria-hidden="true"></i>
2323
</div>

itenium-socks/src/app/socks/sock-reviews.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { Component } from '@angular/core';
33
import { Observable } from 'rxjs';
44
import { SocksService } from './socks.service';
55
import { Review } from './sock.model';
6+
import { TimeagoModule } from 'ngx-timeago';
67

78
@Component({
89
selector: 'app-sock-reviews',
910
standalone: true,
10-
imports: [NgFor, AsyncPipe],
11+
imports: [NgFor, AsyncPipe, TimeagoModule ],
1112
templateUrl: './sock-reviews.component.html'
1213
})
1314
export class SockReviewsComponent {

0 commit comments

Comments
 (0)