angular / angular/components

mat-icon: To be able to have both svgIcon and fontIcon

Abierto
#15,751 4 comentarios 8 reacciones 0 asignados Ver en GitHub
area: material/icon feature P4
Lenguaje dominante
TypeScript
Estrellas
25k
Forks
6.8k
Merge medio
1 d 8 h
PR fusionados (30 d)
91

Descripción

#### Please describe the feature you would like to request.
Let's say you have a js structure (an array of object) holding a list of icons, some svg, some font with other properties.
In your view you want to have a simple *ngFor to iterate on all your icons.
For svg icons, your object will have a "svg" property.
For font icons, your object will have a "font" property.
The key will be undefined if not set.
Therefore, you will have in your loop something like:
`{{ btn.icon }}`
Sounds pretty easy but that's not working right now (Angular Material 7.3.7).

#### What is the use-case or motivation for this proposal?
To simply KISS
To avoid a fugly:
``
`{{ btn.icon }}`

#### Is there anything else we should know?
For what I saw, the reason about that is located in:
https://github.com/angular/material2/blob/master/src/lib/icon/icon.ts#L224-L244

A quick hack could be :
https://github.com/angular/material2/blob/master/src/lib/icon/icon.ts#L237
`!this._usingFontIcon() && this._clearSvgElement();`

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza en src/lib/icon/icon.ts, líneas 224-244, y reproduce el problema con el ejemplo de mat-icon/ngFor de Angular Material 7.3.7 descrito en el informe. Rastrea el procesamiento de svgIcon y fontIcon y verifica después que un mat-icon pueda renderizar cualquiera de las dos formas sin plantillas condicionales, preservando el comportamiento existente.

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
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
38/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.