javascripthtmlangularangular-materialmat-sidenav

ng generate @angular/material:material-nav --name=main-nav generates files correctly but they do not run


I ran a simple command that should generate prebuilt files that would be ready to use as a nav-bar. It downloads correctly but if I add <main-nav></main-nav> to my app.component.html page, it will simply output a blank page. There are no errors in my console. The following is the command: ng generate @angular/material:material-nav --name=main-nav I am using a Mac, Angular 6, and Angular Material. The following is the video that I was following: https://www.youtube.com/watch?v=Q6qhzG7mObU. I've tested each part independently and have found that the <mat-sidenav></mat-sidenav> function does not work at all.


Solution

  • Did you add MatSidenavModule to your app's module?

    @NgModule({
      imports: [
        MatSidenavModule,
        // ...
      ]
    })
    export class AppModule { }