Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

feat(core): shorthand for exposing model input/output pairs in hostDirectives

オープン
#70,748 コメント 1 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
angular, typescript
領域
api, frontend

調査の方向性

Start by reading the core hostDirectives API for separate inputs and outputs, then compare it with model() and twoWayBinding() behavior in createComponent. Trace how aliases and overlapping declarations are handled. Done means a models shorthand supports aliased model input/output pairs without regressions, with coverage for the relevant edge cases.

索引モデルが issue の本文から書いたものです。

説明

area: core core: host directives feature
Which @angular/* package(s) are relevant/related to the feature request?

core

Description

Hey!

Currently, exposing a model through hostDirectives requires listing its input and output separately:

@Directive({ selector: '[dir]' })
export class Dir {
  readonly value = model.required<number>();
}

@Component({
  selector: 'Comp',
  hostDirectives: [
    {
      directive: Dir,
      inputs: ['value: aliasedValue'],
      outputs: ['valueChange: aliasedValueChange'],
    },
  ],
  template: `
    <button (click)="value.set(value() - 1)">-</button>
    <span>{{ value() }}</span>
    <button (click)="value.set(value() + 1)">+</button>
  `,
})
export class Comp {
  protected readonly value = inject(Dir).value;
}

@Component({
  imports: [Comp],
  template: `
    <h3>Value: {{ v() }}</h3>
    <Comp [(aliasedValue)]="v" />
  `,
})
export class App {
  protected readonly v = signal(0);
}

https://stackblitz.com/edit/stackblitz-starters-envjksbm

The hostDirectives API predates model(), so this makes sense. However, since createComponent now supports twoWayBinding(), I think it would be nice to offer a similar convenience in hostDirectives and reduce this boilerplate (assuming details such as overlapping declarations can be addressed). In general, a concrete use case is aria/directives.

So something like this:

hostDirectives: [
    { directive: Dir, models: ['value: aliasedValue'] },
]

Thanks a lot!

Cheers

主要言語
TypeScript
スター
101k
フォーク
28.1k
平均マージ
2日 6時間
マージ済み PR(30日)
307

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

angular/angular のほかの issue

angular/angular の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。