mat-icon: To be able to have both svgIcon and fontIcon #15751
Labels
area: material/icon
feature
This issue represents a new feature or feature request rather than a bug or bug fix
P4
A relatively minor issue that is not relevant to core functions
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:
<mat-icon [matTooltip]="btn.tooltip | translate" [svgIcon]="btn.svgicon">{{ btn.icon }}</mat-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:
<mat-icon *ngIf="btn.svgicon" [matTooltip]="btn.tooltip | translate" [svgIcon]="btn.svgicon"></mat-icon>
<mat-icon *ngIf="!btn.svgicon" [matTooltip]="btn.tooltip | translate">{{ btn.icon }}</mat-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();
The text was updated successfully, but these errors were encountered: