Skip to content

oberconcejo/VS-CODE / .agents/skills/angular-developer

angular-developer

Verified

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

FileKindSize
SKILL.mdskill md10.8 KB
references/angular-animations.mdmarkdown3.9 KB
references/angular-aria.mdmarkdown12.3 KB
references/cli.mdmarkdown3.6 KB
references/component-harnesses.mdmarkdown2.8 KB
references/component-styling.mdmarkdown2.5 KB
references/components.mdmarkdown3.3 KB
references/creating-services.mdmarkdown2.6 KB
references/data-resolvers.mdmarkdown1.5 KB
references/define-routes.mdmarkdown1.7 KB
references/defining-providers.mdmarkdown2.2 KB
references/di-fundamentals.mdmarkdown3.5 KB
references/e2e-testing.mdmarkdown1.9 KB
references/effects.mdmarkdown2.7 KB
references/hierarchical-injectors.mdmarkdown2.0 KB
references/host-elements.mdmarkdown2.1 KB
references/injection-context.mdmarkdown1.9 KB
references/inputs.mdmarkdown2.4 KB
references/linked-signal.mdmarkdown2.5 KB
references/loading-strategies.mdmarkdown1.4 KB
references/mcp.mdmarkdown4.0 KB
references/navigate-to-routes.mdmarkdown1.6 KB
references/outputs.mdmarkdown2.5 KB
references/reactive-forms.mdmarkdown3.5 KB
references/rendering-strategies.mdmarkdown1.8 KB
references/resource.mdmarkdown2.7 KB
references/route-animations.mdmarkdown1.6 KB
references/route-guards.mdmarkdown1.4 KB
references/router-lifecycle.mdmarkdown1.5 KB
references/router-testing.mdmarkdown3.8 KB
references/show-routes-with-outlets.mdmarkdown1.6 KB
references/signal-forms.mdmarkdown23.6 KB
references/signals-overview.mdmarkdown2.8 KB
references/tailwind-css.mdmarkdown1.8 KB
references/template-driven-forms.mdmarkdown3.7 KB
references/testing-fundamentals.mdmarkdown2.6 KB

references/components.md

View on GitHub
# Components

Angular components are the fundamental building blocks of an application. Each component consists of a TypeScript class with behaviors, an HTML template, and a CSS selector.

## Component Definition

Use the `@Component` decorator to define a component's metadata.

```ts
@Component({
  selector: 'app-profile',
  template: `
    <img src="profile.jpg" alt="Profile photo" />
    <button (click)="save()">Save</button>
  `,
  styles: `
    img {
      border-radius: 50%;
    }
  `,
})
export class Profile {
  save() {
    /* ... */
  }
}
```

## Metadata Options

- `selector`: The CSS selector that identifies this component in templates.
- `template`: Inline HTML template (preferred for small templates).
- `templateUrl`: Path to an external HTML file.
- `styles`: Inline CSS styles.
- `styleUrl` / `styleUrls`: Path(s) to external CSS file(s).
- `imports`: Lists the components, directives, or pipes used in this component's template.

## Using Components

To use a component, add it to the `imports` array of the consuming component and use its selector in the template.

```ts
@Component({
  selector: 'app-root',
  imports: [Profile],
  template: `<app-profile />`,
})
export class App {}
```

## Template Control Flow

Angular uses built-in blocks for conditional rendering and loops.

### Conditional Rendering (`@if`)

Use `@if` to conditionally show content. You can include `@else if` and `@else` blocks.

```html
@if (user.isAdmin) {
<admin-dashboard />
} @else if (user.isModerator) {
<mod-dashboard />
} @else {
<standard-dashboard />
}
```

**Result aliasing**: Save the result of the expression for reuse.

```html
@if (user.settings(); as settings) {
<p>Theme: {{ settings.theme }}</p>
}
```

### Loops (`@for`)

The `@for` block iterates over collections. The `track` expression is **required** for performance and DOM reuse.

```html
<ul>
  @for (item of items(); track item.id; let i = $index, total = $count) {
  <li>{{ i + 1 }}/{{ total }}: {{ item.name }}</li>
  } @empty {
  <li>No items to display.</li>
  }
</ul>
```

**Implicit Variables**: `$index`, `$count`, `$first`, `$last`, `$even`, `$odd`.

### Switching Content (`@switch`)

The `@switch` block renders content based on a value. It uses strict equality (`===`) and has **no fallthrough**.

```html
@switch (status()) { @case ('loading') { <app-spinner /> } @case ('error') { <app-error-msg /> }
@case ('success') { <app-data-grid /> } @default {
<p>Unknown status</p>
} }
```

**Exhaustive Type Checking**: Use `@default never;` to ensure all cases of a union type are handled.

```html
@switch (state) { @case ('on') { ... } @case ('off') { ... } @default never; // Errors if a new
state like 'standby' is added }
```

## Core Concepts

- **Host Element**: The DOM element that matches the component's selector.
- **View**: The DOM rendered by the component's template inside the host element.
- **Standalone**: By default, components are standalone (since Angular 19, `standalone: true` is default). For older versions, `standalone: true` must be explicit or the component must be part of an `NgModule`.
- **Component Tree**: Angular applications are structured as a tree of components, where each component can host child components.
- **Component Naming**: Do not add suffixes the `Component` suffix for Component classes (e.g., AppComponent) unless the project has been configured to use that naming configuration.
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 319kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 319kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 319kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 196kUpdated Claude CodeCodexVerifiedInstall