Pushing a page on startup of app



  • Hi, I was wondering how one would go about pushing a page on the startup of the application. I have a component I want to use on startup for a login page. I do a simple push page in ngOnInit but console says property ‘element’ is undefined.

    @ViewChild(OnsNavigator) private _navigator: OnsNavigator;
    
    ngOnInit() {
    this._navigator.element.pushPage(SelectWicProviderPage);
    }
    

    Is this because the component I want to load has not initialized yet(SelectWicProviderPage)?



  • Answering my own question here: The problem was that I simply did not have a <ons-navigator> tags wrapping the corresponding html page for the component. After wrapping the page in those tags, navigating worked fine.


Log in to reply