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
- Lenguaje dominante
- TypeScript
- Estrellas
- 25k
- Forks
- 6.8k
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 91
Descripción
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.
Guía de contribución
Línea de trabajo
Comienza con la documentación enlazada de Angular Material sobre autocompletado, especialmente la sección sobre cómo establecer valores separados para el control y la visualización, y compárala con el ejemplo de user object del issue. Se considera terminado cuando un autocompletado puede mostrar user.name después de la selección, mientras envía user.id en lugar del nombre o del objeto completo.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- angular, typescript
- Área
- frontend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100