I'm new to Angular/material2 and I'm unsure of what I'm missing from trying to follow the documentation on sidenav
.
In my AppComponent, I would like to display a sidenav and I've implemented as follows:
app.component.tss
import {
NgModule,
Component
} from '@angular/core';
import {
MatSidenavModule,
MatSidenavContent,
MatSidenav
} from '@angular/material';
import {
BrowserAnimationsModule
} from '@angular/platform-browser/animations';
@NgModule({
imports: [
BrowserAnimationsModule,
MatSidenav
],
exports: [
BrowserAnimationsModule,
MatSidenav
]
})
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
}
app.component.html
<!--The content below is only a placeholder and can be replaced.-->
<mat-sidenav-container>
</mat-sidenav-container>
<div style="text-align:center">
<h1>
Welcome to {{ title }}!
</h1>
<nav>
<a routerLink="/clients">Clients</a>
</nav>
<router-outlet>
</router-outlet>
</div>]
The error is:
Uncaught Error: Template parse errors:
'mat-sidenav-container' is not a known element:
1. If 'mat-sidenav-container' is an Angular component, then verify that it is part of this module.
2. If 'mat-sidenav-container' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message
What am I missing in my code?