components: md-icon svgSrc dont work

I installed fresh,the latest Version of Material2.

md-icon: <md-icon svgSrc="img/icons/social/facebook.svg"></md-icon>

dont give out any icon. In Material1 it include the svg code in the html template. But for me in new Material absolutly nothing happens. I dont get any error to.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

@BamiGorengo You will need to add the icons explicitly in the icon registry. For an example, look at the src/demo-app/icon/icon-demo.ts, specifically the constructor:

  constructor(mdIconRegistry: MdIconRegistry, sanitizer: DomSanitizer) {
    mdIconRegistry
        .addSvgIcon('thumb-up',
            sanitizer.bypassSecurityTrustResourceUrl('/icon/assets/thumbup-icon.svg'));
    // ...      
  }

The “thumb-up” icon is then usable as is show in the src/demo-app/icon/icon-demo.html

<md-icon svgIcon="thumb-up"></md-icon>

I would also like to know if there is a way to register all icons globally