I'm trying to use angular material 2 to display icons on my website, but I'm a little confused.
This is how it's supposed to work, from the demo in github repo of material 2:
https://github.com/angular/material2/blob/master/src/demo-app/icon/icon-demo.ts
I've been trying to use it but no icons are shown at all.
This is how I set it up:
app.component.ts
import {MdIcon, MdIconRegistry} from '@angular2-material/icon/icon';
@Component({
...
encapsulation: ViewEncapsulation.None,
viewProviders: [MdIconRegistry],
directives: [MdIcon],
})
export class MyComponent{
constructor(private router: Router,
private JwtService:JwtService,
mdIconRegistry: MdIconRegistry){
mdIconRegistry.addSvgIconSetInNamespace('core', 'fonts/core-icon-set.svg')
}
}
and the template..
<md-icon>home</md-icon>
The page loads with no errors, but no icon is shown. What could have gone wrong?
icon-demo
is somewhere available online as well. You can compare the DOM of the icon in your application and the one in the demo. Maybe it gives some hint what might have went wrong. – Günter Zöchbauer