Registers a Material icon set in the default namespace.
WARNING: The icons string you pass in will bypass Angular's security measures! Including untrusted user data will expose your application to XSS security risks!
By default, Angular Material configures your app to download font files that include all material icons. This is a helper for a technique to:
only download the icons your app uses
eliminate flickering in the UI that otherwise happens before the fonts load
reduce the number of network requests needed to load your app
This technique requires you to manually download each icon you use, clean up its SVG source, and paste it into your source code. For example, you might create a file called icons.ts that looks like this, which contains two icons:
Set the "Optical size" to 24px. You are free to modify other customizations.
Download the SVG and paste its contents into your icons string.
Set an id on the <svg> tag to the name of the icon.
Delete any hard-coded colors (e.g. fill="#000000")
At this point your icon should be working. If you care to, you can delete unnecessary attributes from the SVG, such as xmlns, width and height. Experiment to see if anything else can be eliminated.
Registers a Material icon set in the default namespace.
WARNING: The
icons
string you pass in will bypass Angular's security measures! Including untrusted user data will expose your application to XSS security risks!By default, Angular Material configures your app to download font files that include all material icons. This is a helper for a technique to:
This technique requires you to manually download each icon you use, clean up its SVG source, and paste it into your source code. For example, you might create a file called
icons.ts
that looks like this, which contains two icons:Then in your
app.config
orapp.module
, include it in yourproviders
array like this:Finally, display the icons in a template like this, where
svgIcon
matches theid
you gave it aboveTo construct the
icons
string using svgs from the material team:icons
string.id
on the<svg>
tag to the name of the icon.fill="#000000"
)xmlns
,width
andheight
. Experiment to see if anything else can be eliminated.