activity-feed.component.ts
angular/examples/week05-06/src/app/activity-feed.component.ts
// @ts-nocheck
import { Component, inject } from '@angular/core';
import { AsyncPipe, NgFor, NgIf } from '@angular/common';
import { MetricsService } from './metrics.service';
@Component({
selector: 'app-activity-feed',
standalone: true,
imports: [AsyncPipe, NgFor, NgIf],
template: `
<section *ngIf="projects$ | async as projects; else loading">
<h2>Recent Activity</h2>
<ul>
<li *ngFor="let item of projects">
<span class="name">{{ item.name }}</span>
<span class="status" [class.active]="item.status === 'active'">{{ item.status }}</span>
</li>
</ul>
</section>
<ng-template #loading>
<p>Loading activity…</p>
</ng-template>
`,
styles: [
`
ul {
display: grid;
gap: 0.75rem;
}
li {
display: flex;
justify-content: space-between;
padding: 0.75rem 1rem;
border-radius: 0.75rem;
border: 1px solid #e5e7eb;
}
.status.active {
color: #16a34a;
font-weight: 600;
}
`,
],
})
export class ActivityFeedComponent {
private metricsService = inject(MetricsService);
projects$ = this.metricsService.fetchProjects();
}
Articoli correlati
server.js
server.js — javascript source code from the angular learning materials (angular/comprehensive-demo/server/server.js).
Leggi l'articolo →app.component.ts
app.component.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/app.component.ts).
Leggi l'articolo →app.config.ts
app.config.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/app.config.ts).
Leggi l'articolo →app.routes.ts
app.routes.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/app.routes.ts).
Leggi l'articolo →auth.guard.ts
auth.guard.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/core/guards/auth.guard.ts).
Leggi l'articolo →role.guard.ts
role.guard.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/core/guards/role.guard.ts).
Leggi l'articolo →