Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70891

How Do We Detect Component Initialization?

$
0
0

@marrobin wrote:

For example, I want to disable swipe on my side menu, but this can't be done until the side menu's ngOnInit method has fired.

@brandyshea I saw you gave this example in issue 5390

import {MenuController} from 'ionic/ionic';

constructor(menu: MenuController) {
this.menu = menu;
let menuOpen = this.menu.get().isOpen;
console.log( menuOpen );
}

In my experience, the MenuController is useless in the constructor of the page, because the menu components have not yet registered themselves with the MenuController. I've tested onPageLoaded and onPageDidEnter lifecycle hooks too, and they are no good. The only thing that works for me is to create a setTimeout and wait a few ticks for the MenuController to have its _menu array populated with the menu components on the page.

Would love some advice on this. Seems like a fundamental requirement.Thanks!

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70891

Trending Articles