Angular - Hide sidebar menu after clicking a menu item

后端 未结 5 2028
天命终不由人
天命终不由人 2021-02-07 13:32

I created a sidebar menu, but I am not able to hide the menu after I click on a menu item. I followed the example from https://blog.thecodecampus.de/angular-2-animate-creating-s

5条回答
  •  情话喂你
    2021-02-07 13:41

    You have to do the toggle things in NgZone. And for that first you have to add following module.

    import { NgZone } from '@angular/core';
    

    Now create zone variable in constructor

    constructor(public zone: NgZone){}
    

    and write your toggle logic in Zone() method like following way

    toggleMenu() {
        this.zone.run(()=>{
        this.menuState = this.menuState === 'out' ? 'in' : 'out';
       })
    }
    

提交回复
热议问题