Following docs:
https://material.angular.io/components/icon/overview#icon-sets
And this guide:
https://materialdesignicons.com/getting-started
I wrote this:
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { FeaturesModule } from './features/features.module';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatIconRegistry, MatIconModule } from '@angular/material';
import { DomSanitizer } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpClientModule,
MatIconModule,
AppRoutingModule,
FeaturesModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
constructor(matIconRegistry: MatIconRegistry, domSanitizer: DomSanitizer) {
matIconRegistry.addSvgIconSet(
domSanitizer.bypassSecurityTrustResourceUrl('./assets/icons/mdi.svg')
);
}
}
Then in the template app.component.html:
<mat-icon svgIcon="android"></mat-icon>
<router-outlet></router-outlet>
and also I have set up assets in the angular-cli.json.
But when I load the page I get:
Error retrieving icon: Unable to find icon with the name "android"
the thing is, the .svg file is being loaded:
Maybe I'm missing something.
How to add correctly an Iconset in angular material 2?
