Angular - Hide sidebar menu after clicking a menu item

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';
   })
}

You can handle that in router events and set this.menuState to 'out' whenever route changes.

A pretty decent sample code here