angular / angular/components

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

Đang mở
#15,751 4 bình luận 8 reaction 0 người được giao Xem trên GitHub
area: material/icon feature P4
Ngôn ngữ chính
TypeScript
Star
25k
Fork
6.8k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
91

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu tại src/lib/icon/icon.ts, các dòng 224-244, và tái hiện vấn đề với ví dụ mat-icon/ngFor của Angular Material 7.3.7 được mô tả trong báo cáo. Theo dõi cách xử lý svgIcon và fontIcon, sau đó xác minh rằng một mat-icon có thể render cả hai dạng mà không cần các template có điều kiện, đồng thời giữ nguyên hành vi hiện có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
frontend
Loại issue
Tính năng
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
38/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.