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
- Lingua principale
- TypeScript
- Stelle
- 25k
- Fork
- 6.8k
- Merge medio
- 1g 8h
- PR unite (30g)
- 91
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia dalla documentazione collegata di Angular Material sull’autocompletamento, in particolare dalla sezione sull’impostazione di valori separati per il controllo e la visualizzazione, e confrontala con l’esempio di user object nell’issue. Il lavoro è completato quando un autocompletamento può visualizzare user.name dopo la selezione, inviando user.id invece del nome o dell’intero oggetto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- angular, typescript
- Ambito
- frontend
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100