Support for setting option's control value to be a property of object and option's display value to be another property of the object
- 主要言語
- TypeScript
- スター
- 25k
- フォーク
- 6.8k
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 91
説明
I know that if we want the option's control value (what is saved in the form) to be different than the option's display value (what is displayed in the text field), we'll need to set the **displayWith** property on our autocomplete element. as explained here:
https://material.angular.io/components/autocomplete/overview#setting-separate-control-and-display-values
Suppose we have a user object like `{ id: 1, name: 'Abc' }`.
What if we want the option's control value (what is saved in the form) to be **user.id** and option's display value (what is displayed in the actual text field) to be **user.name**?
In my case I want to display a list of users in autocomplete options and when user selects a user, I want to display the selected user name on the user screen but when the form is submitted, I just want user.id to be posted to the server not user.name and not complete user object.
コントリビューションガイド
調査の方向性
リンクされている Angular Material のオートコンプリートのドキュメントから始め、特にコントロール値と表示値を分けて設定するセクションを確認し、issue にある user object の例と比較してください。選択後にオートコンプリートが user.name を表示し、名前やオブジェクト全体ではなく user.id を送信できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- angular, typescript
- 領域
- frontend
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100