Angular 2 material : sidenav toggle from component

前端 未结 4 1740
挽巷
挽巷 2021-02-04 05:28

I\'m using Angular 2 Material sidenav in my project this way:


  
      

        
4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-04 06:18

    The simplest way for was to pass the drawer to the component that triggers the toggle.

    Html:

    
        ....
    
    
    
    

    another-component TS:

    export class AnotherComponent implements OnInit {
       @Input() drawerRef: MatDrawer;
       ...
    }
    

    another-component HTML:

    Where another-component is the component that controls the toggle action.

提交回复
热议问题