Angular Components
ASecurityUse `computed()` for derived values that depend on signals. A computed signal is memoized and recalculates when one of its tracked signal dependencies changes. Calling an arbitrary calculation from interpolation can repeat that work during change-detection checks. ```ts import { ChangeDetectionStrategy, Component, computed, input, signal, } from '@angular/core'; interface User { id: string; name: string; } @Component({ selector: 'app-filtered-users', standalone: true, imports: [], changeDetec...
- 584 stars
- 0 votes
- 0 copies
- 4 views
- Added September 5, 2026
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-0fd859ab)# `computed` signals versus functions in templates
Use `computed()` for derived values that depend on signals. A computed signal is memoized and recalculates when one of its tracked signal dependencies changes. Calling an arbitrary calculation from interpolation can repeat that work during change-detection checks.
```ts
import {
ChangeDetectionStrategy,
Component,
computed,
input,
signal,
} from '@angular/core';
interface User {
id: string;
name: string;
}
@Component({
selector: 'app-filtered-users',
standalone: true,
imports: [],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<input
type="search"
[value]="query()"
(input)="query.set(($any($event.target)).value)"
/>
@for (user of visibleUsers(); track user.id) {
<p>{{ user.name }}</p>
} @empty {
<p>No matching users.</p>
}
`,
})
export class FilteredUsersComponent {
readonly users = input.required<readonly User[]>();
readonly query = signal('');
readonly visibleUsers = computed(() => {
const term = this.query().trim().toLowerCase();
return this.users().filter((user) => user.name.toLowerCase().includes(term));
});
}
```
The template reads `visibleUsers()`; it does not call a `filterUsers()` or `calculate()` method for interpolation. Event-handler methods are still appropriate for actions, but keep derived presentation state in `computed()` (or use a pipe for reusable formatting). The computed value remains compatible with standalone components and 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.