Angular Components
ASecurityThe pattern separates orchestration from presentation: - A smart/container component injects services, owns loading/error/state decisions, and handles business actions. - A dumb/presentational component has no service dependencies. It receives data through signal inputs and reports user intent through `output()` events. For example, the presentational component can stay focused on rendering: ```ts import { ChangeDetectionStrategy, Component, input, output, } from '@angular/core'; interface Us...
- 584 stars
- 0 votes
- 0 copies
- 2 views
- Added September 5, 2026
Works with
Security analysis
100/100Pro scans all 21 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill angular-components --agent claude-codeAre you the author of Angular Components?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-angular-components-bef9196a)# The Smart/Dumb component pattern
The pattern separates orchestration from presentation:
- A smart/container component injects services, owns loading/error/state decisions, and handles business actions.
- A dumb/presentational component has no service dependencies. It receives data through signal inputs and reports user intent through `output()` events.
For example, the presentational component can stay focused on rendering:
```ts
import {
ChangeDetectionStrategy,
Component,
input,
output,
} from '@angular/core';
interface User {
id: string;
name: string;
}
@Component({
selector: 'app-user-list',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
@for (user of users(); track user.id) {
<button type="button" (click)="selectUser(user)">
{{ user.name }}
</button>
} @empty {
<p>No users.</p>
}
`,
})
export class UserListComponent {
readonly users = input.required<readonly User[]>();
readonly selected = output<User>();
selectUser(user: User): void {
this.selected.emit(user);
}
}
```
The smart parent owns the service and connects the child to it:
```ts
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
@Component({
selector: 'app-user-page',
standalone: true,
imports: [UserListComponent],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<app-user-list
[users]="users()"
(selected)="selectUser($event)"
/>
`,
})
export class UserPageComponent {
private readonly usersApi = inject(UsersApi);
readonly users = toSignal(this.usersApi.users$, { initialValue: [] });
selectUser(user: User): void {
this.usersApi.select(user.id);
}
}
```
The parent example also requires `inject` and `toSignal` imports from `@angular/core` and `@angular/core/rxjs-interop`. This boundary makes the dumb component reusable and easy to test, while the smart component remains responsible for service interaction. Both components are standalone and use OnPush.
Files in this skill
- eval-1.baseline.md
- eval-1.with-skill.md
- eval-2.baseline.md
- eval-2.with-skill.md
- eval-3.baseline.md
- eval-3.with-skill.md
- eval-4.baseline.md
- eval-4.with-skill.md
- eval-5.baseline.md
- eval-5.with-skill.md
- eval-6.baseline.md
- eval-6.with-skill.md
- eval-7.baseline.md
- eval-7.with-skill.md
- eval-8.baseline.md
- eval-8.with-skill.md
- eval-9.baseline.md
- eval-9.with-skill.md
- trigger-1.md
- trigger-2.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.