angular-components について
Angular アプリケーション開発者向けのコンポーネント設計リファレンスです。スタンドアロンコンポーネント、signal ベースの入出力、テンプレート、変更検知、カプセル化、ホストバインディングを扱います。
主な機能
- 01スタンドアロンコンポーネントの作成
- 02signal ベースの入出力
- 03テンプレートとコンテンツ投影の設定
- 04変更検知とカプセル化の設定
- 05ホストのプロパティとイベントのバインド
活用シーン
- 01再利用可能なスタンドアロンコンポーネントの構築
- 02コンポーネントの入力とイベント出力の定義
- 03描画とコンポーネントスタイルの設定
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ oguzhan18/ angular-ecosystem-skills --skill angular-componentsインストール後、Claude Code で/angular-componentsを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
references/discussions/_INDEX.mdreferences/docs/_INDEX.mdreferences/issues/_INDEX.mdreferences/releases/_INDEX.md詳細
Angular コンポーネント
バージョン: Angular 21(2025) タグ: コンポーネント、@Component、アーキテクチャ
参考資料: コンポーネントガイド • @Component API
ベストプラクティス
- スタンドアロンコンポーネントを作成する
@Component({
standalone: true,
selector: 'app-my',
imports: [CommonModule],
template: `<p>Content</p>`
})
export class MyComponent {}
- シグナルを使って入力を受け取る
@Component({})
export class MyComponent {
data = input<string>('');
required = input.required<User>();
computed = computed(() => this.data()?.name);
}
- イベントには出力を使う
@Component({})
export class MyComponent {
data = output<string>();
onClick() {
this.data.emit('event');
}
}
- テンプレート参照変数を使う
@Component({
template: `
<input #nameInput>
<button (click)="onSubmit(nameInput.value)">Submit</button>
`
})
export class MyComponent {}
- コンテンツ投影を使う
@Component({
selector: 'app-card',
template: `
<div class="header">
<ng-content select="[header]"></ng-content>
</div>
<div class="body">
<ng-content></ng-content>
</div>
`
})
export class CardComponent {}
- 変更検出戦略を使う
@Component({
changeDetection: ChangeDetectionStrategy.OnPush
})
export class OptimizedComponent {}
- カプセル化を使う
@Component({
encapsulation: ViewEncapsulation.None // or Emulated, ShadowDom
})
export class StyledComponent {}
- ホストバインディングを使う
@Component({
host: {
'[class.active]': 'isActive',
'(click)': 'onClick()'
}
})
export class HostComponent {
isActive = false;
}
コメント
Markdown 対応