feat(core): shorthand for exposing model input/output pairs in hostDirectives
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- angular, typescript
調査の方向性
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 の本文から書いたものです。
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
angular/angular のほかの issue
-
area: docs
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
area: forms forms: signals
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
area: docs gemini-triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
area: forms forms: signals
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
area: docs area: forms
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
angular/angular の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
vercel-labs/just-bash#464 ·
-
looksLikeSlug() is ASCII-only, so non-Latin entity slugs (e.g. Korean) skip exact match and collapse オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
TanStack/tanstack.com#1293 ·