I did not succeed to format my code in a comment :/
import { Component, ElementRef } from '@angular/core';
@Component({
selector: 'page-home',
templateUrl: 'home.html',
host:{'(document:click)': 'onClick($event)',
}
})
export class HomePage {
constructor(public navCtrl: NavController, private element: ElementRef) {
}
onClick(event) {
// display event in console if outside of menu top bar
if (this.element.nativeElement.contains(event.target)) {
console.log(event);
this.closeMenu();
} else {
this.openMenu();
}
openMenu() {
this.showMoreBarItem = !this.showMoreBarItem;
}
closeMenu() {
if(this.showMoreBarItem) {
this.showMoreBarItem = !this.showMoreBarItem;
}
}}
IMPORTANT : You have to separate your menu component to accomplish it, and only apply my changes in your menu component => in your case create a new component in home.html for instance !