I had the same problem. I followed these steps (in this exact order, this is VERY important):
This happens mainly because Angular won't build those modules in the correct order, i.e before the HTML.
e.g My code:
<mat-toolbar> <!-- 2 -->
<button mat-icon-button class="example-icon" aria-label="Example icon-button with menu icon">
<mat-icon>favorite</mat-icon> <!-- 1 -->
</button>
<span>My App</span>
<span class="example-spacer"></span>
<button mat-icon-button class="example-icon favorite-icon" aria-label="Example icon-button with heart icon">
</button>
<button mat-icon-button class="example-icon" aria-label="Example icon-button with share icon">
</button>
</mat-toolbar>
_x000D_