angular / angular/components

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

オープン
#15,751 コメント 4 件 リアクション 8 件 担当者 0 名 GitHub で見る
area: material/icon feature P4
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
91

説明

#### 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();`

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

src/lib/icon/icon.ts の224-244行目から始め、報告で説明されている Angular Material 7.3.7 の mat-icon/ngFor の例で問題を再現します。svgIcon と fontIcon の処理を追跡し、その後、既存の動作を維持しながら、1つの mat-icon で条件付きテンプレートなしにどちらの形式もレンダリングできることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。