How to Import "Page" in Ionic 3


#1

Hi, I am in the process of updating my Ionic 2 project to Ionic >=3.

One of the changes seems to be what argument type NavController now no longer takes a Component argument…

abstract setRoot(pageOrViewCtrl: Page | string | ViewController, params?: any, opts?: NavOptions, done?: Function): Promise<any>;`

I have an existing method that returned a Component as follows…

public async getInitialPageForLoginState(: Promise<Component> {
 ...

With a call like the following

let page = await this.appStartupService.getInitialPageForLoginState()`
this.navCtrl.setRoot(page);

Which now gets a type error. Rather than change the return type to Promise<any>, I would like to change it to Promise<Page> but cannot find where to import Page from.

Does any one know how to import this?

Thanks in advance.


#2

I believe it’s defined in ionic-angular/navigation/nav-util, although if you are lazily loading pages, you need to pass strings instead.


#3

Great thankyou, an good point re the lazy loading (not done yet, but possibly a next step)