angular / angular/components

docs-bug(MatInput): How to nest / wrap material form controls

Abierto
#23,850 11 comentarios 19 reacciones 0 asignados Ver en GitHub
area: material/input docs good first issue help wanted P3
Lenguaje dominante
TypeScript
Estrellas
25k
Forks
6.8k
Merge medio
1 d 8 h
PR fusionados (30 d)
91

Descripción

#### Documentation Feedback

I find myself getting stuck on this again and again, and I've been using angular and material since it's inception, so by now it should have stuck up there in the old noggin, but alas.

Today we have a basic tutorial on how to do a completely custom form field
https://material.angular.io/guide/creating-a-custom-form-field-control

but there is no tutorials examples of how to take an existing matInput mat-select or other form controls and wrap them into a component.
Usually we need to do this to DRY things up and not have to have the same error messages, options or reoccurring fields multiple times.

## These are some tutorials / examples I would like to see

**Custom component to wrap sub field names, validation and errors**
I have an Address FormGroup which contains
street, zipcode, city
and a couple of mat-form-fields with labels, inputs, errors
I now want to wrap this into a ``

**Custom `mat-select` with static list of values and validation**
I have a Language select that is reused in multiple places
I now want to use it ``

**Custom `input with some kind of dialog picker`**
A User picker, should display the user name when done, and an icon to the right much like a date picker.
but then in the dialog we have some custom logic to list all users, and the value that comes out of the picker should be the database id for the user.
``

## The struggles
Since matInput already implements ControlValueAccessor it must be possible to just provide / delegate functionality down to that child, but how?

I have multiple implementations of the above, but all of them feel over complicated, or the dirty state isn't working because of something.

We need best practices for creating wrapped form controls and form groups :)

Please let me know if you need more context or examples, I have plenty

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con la guía enlazada de Angular Material sobre la creación de un control de campo de formulario personalizado y compárala con los ejemplos solicitados de matInput, mat-select, form-group y picker envueltos. Define el alcance y los patrones recomendados antes de añadir tutoriales; se considera terminado cuando la documentación explica los controles y grupos envueltos con ejemplos completos, validación y el comportamiento del estado del formulario.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
documentation
Tipo de issue
Documentación
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
28/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.