I am having a problem using a registered icon in Angular Material 2. I have followed the example of their github repository but without luck.
In my AppComponent:
constructor(mdIconRegistry: MdIconRegistry, sanitizer: DomSanitizer) {
mdIconRegistry
.addSvgIcon('thumb-up',
sanitizer.bypassSecurityTrustResourceUrl('./thumbup-icon.svg'))
}
Template:
<md-icon svgIcon="thumb-up"></md-icon>
In the console, I am getting error "Error retrieving icon: undefined". So it knows it is registered and most likely there is a problem with the path. I have already tried many different variations of the path and none has worked. For the simplicity, let's assume that SVG file is in the app folder alongside app.component.ts
There is similar (closed) issue on github that is also not answered so I know I am not the only one having this issue. I am using Angular CLI and I guess that it also may be a problem with configuration.
Structure
- src
- app
- app.component.ts
- // I have tried putting SVG here
- ...
- assets
- // I have also tried putting SVG here
- ...
- ...
- app