activity-feed.component.ts
angular/examples/week05-06/activity-feed.component.ts
// @ts-nocheck
import { Component, Input } from '@angular/core';
import { NgFor } from '@angular/common';
@Component({
selector: 'app-activity-feed',
standalone: true,
imports: [NgFor],
template: `
<section>
<h2>Recent Activity</h2>
<ul>
<li *ngFor="let item of activity">
<span class="name">{{ item.name }}</span>
<span class="status" [class.active]="item.status === 'active'">{{ item.status }}</span>
</li>
</ul>
</section>
`,
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 {
@Input({ required: true }) activity: { name: string; status: string }[] = [];
}
相关文章
server.js
server.js — javascript source code from the angular learning materials (angular/comprehensive-demo/server/server.js).
阅读文章 →app.component.ts
app.component.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/app.component.ts).
阅读文章 →app.config.ts
app.config.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/app.config.ts).
阅读文章 →app.routes.ts
app.routes.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/app.routes.ts).
阅读文章 →auth.guard.ts
auth.guard.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/core/guards/auth.guard.ts).
阅读文章 →role.guard.ts
role.guard.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/core/guards/role.guard.ts).
阅读文章 →