I am using (angular2) want to hide the side menu on clicking any of its links.
I read this question & its accepted answer referenced in this article.
the solution works good if the user click on [routerLink]
other than the currently active one. but ith the current active link is clicked no event emitted.
this is the code:
constructor(
private router: Router,
public zone: NgZone) {
router.events.subscribe( (event: Event) => {
if (event instanceof NavigationStart) {
// Show loading indicator
}
if (event instanceof NavigationEnd) {
// Hide loading indicator
this.w3_close(); // function to hide the menu
}
if (event instanceof NavigationError) {
// Hide loading indicator
// Present error to user
console.log(event.error);
}
});
}