dashboard.component.ts
angular/examples/week05-06/dashboard.component.ts
// @ts-nocheck
import { Component, inject } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { MetricsService } from './metrics.service';
@Component({
selector: 'app-dashboard',
standalone: true,
imports: [RouterOutlet],
template: `
<section class="dashboard">
<header>
<h1>Analytics Dashboard</h1>
<button type="button" (click)="refresh()">Refresh Data</button>
</header>
<nav>
<a routerLink="metrics" routerLinkActive="active">Metrics</a>
<a routerLink="activity" routerLinkActive="active">Activity</a>
</nav>
<section class="outlet">
<router-outlet></router-outlet>
</section>
</section>
`,
styles: [
`
.dashboard {
display: grid;
gap: 1.5rem;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
}
nav {
display: inline-flex;
gap: 1rem;
}
a {
text-decoration: none;
color: #1d4ed8;
}
a.active {
font-weight: 700;
border-bottom: 2px solid currentColor;
}
button {
border: none;
background: #2563eb;
color: white;
padding: 0.5rem 1rem;
border-radius: 0.5rem;
cursor: pointer;
}
`,
],
})
export class DashboardComponent {
private metrics = inject(MetricsService);
refresh(): void {
this.metrics.refresh();
}
}
관련 글
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).
글 읽기 →