Open/Close sidenav from another component

后端 未结 6 956
误落风尘
误落风尘 2020-12-02 12:26

I use angular (latest version) and angular material.

There are 3 components:

  • header.component, in which there is a control button for right-sidenav
6条回答
  •  时光取名叫无心
    2020-12-02 12:52

    If you are working in Angular 9+ Remember add param of static: true in @ViewChild like:

    @ViewChild('rightSidenav', {static: true}) sidenav: MatSidenav;

    You can see my code working on Angular 9 here:

    https://stackblitz.com/edit/angular-kwfinn-matsidenav-angular9

提交回复
热议问题