mat-icon: To be able to have both svgIcon and fontIcon
- Dominant language
- TypeScript
- Stars
- 25k
- Forks
- 6.8k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 91
Description
#### 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();`
Contributor guide
Research direction
Start at src/lib/icon/icon.ts lines 224-244 and reproduce the issue with the Angular Material 7.3.7 mat-icon/ngFor example described in the report. Trace the handling of svgIcon and fontIcon, then verify that one mat-icon can render either form without conditional templates while preserving existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100