Skip to content

[md-icon] Unable to find icon in svg set. Possible bug #1016

@RoxKilly

Description

@RoxKilly

I just upgraded from ng2 rc4 with material2 alpha6 to ng2 rc5 with material 2 alpha7-2. A new error pops up on code that worked before when I use md-icon. It may be a bug.

I cannot see the full error text because instead I get Observable_1.Observable.throw is not a function error (the app crashes), with the top lines in the stacktrace being:

MdIconRegistry.prototype.getNamedSvgIcon @angular2-material/icon/icon-registry.js:180:16
MdIcon.prototype.ngOnChanges @angular2-material/icon/icon.js:107:17

If I console.log() the id of the icon sought just above icon-registry.js @ line 180, I see ic_lightbulb_outline_24px. This icon is present in my svg sprite, but it displayed properly before I upgraded today to material 2 alpha 7-2. Here is its section in the svg sprite:

...</svg> <svg viewBox="0 0 24 24" id="ic_lightbulb_outline_24px"><path d="..."/></svg>...

The template:

<md-icon svgIcon="ic_lightbulb_outline_24px"></md-icon>

In my main AppComponent I have

this._iconRegistry.addSvgIconSet('src/icons/sprite.defs.svg');

I've also imported MdIconModule into the main AppModule. What's really puzzling is that

  • the same icon from the same sprite file works on other components and
  • this worked before the upgrade!

Any ideas?
(cross-posted on StackOverflow)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions