I have recently upgraded to ionic 3 implementing the IonicPageModule for navigation. The push and setRoot works for all navigating however i am stuck at the trying to reference the pages in the app.component.ts
Normally i would reference the page from the import like so
this.rootPage = user ? ProgramsPage : LoginPage;
Where LoginPage and ProgramPage are declared in the app.module.ts
However in the new angular 4 / ionic 3 setup references to the “pages” are referenced with strings without an import in the related page.ts and seemly integrated with the navCtrl’s push and set
I have tried
import { LoginPageModule } from '../pages/login/login.module';
But that does not make sense.
I figured the whole point of creating modules per page was to firstly enalble lazy loading but also minimize the import code on pages without having to create a config export class.
And the thing is you cannot declare the LoginPage twice and seeing as though it is already declared as a module through the IonicPageModule one cannot add that export class again.
So just wondering how do you reference a ionic 3 page component when you want to apply logic?
EDIT
Just thought i would note that the generated templates for sidemenu and tabs still uses the “old way” without creating modules for the page components, yet if you generate a page with ionic g page foobar you get the new module based page component.
ok so your IDE manages imports … ok fine. I was just trying you make you understand the issue i am having which still occurs regardless of amazing IDE xyz
Look, the fundamental thing you asked was “how do you reference a ionic 3 page component?” and the answer is “as a string containing the name of the class”.
Right , so no that was not the fundamental thing that i asked, rather is it how can i handle a reference in the app.component.ts file ot a page module and apply conditional logic, because you cannot reference the page module as a sting in that file, but thanks anyway
Obviously this assumes you have actually bought into the lazy page loading. Rereading your initial post, you say both “implementing the IonicPageModule for navigation” and “LoginPage and ProgramPage are declared in the app.module.ts”, which seems to be a contradiction. If you are declaring pages in your app module, instead of in their own @IonicPageModule, then navigating by strings won’t work and you need to keep importing their class and using that. If you are actually using IonicPageModule for navigation, assigning strings works.
Well obviously not that exact code because I don’t have pages with the same names as yours, but the fundamental idiom of:
<ion-nav [root]="rootPage">
backed by strings in rootPage, yes. I’m not currently using it now, though, because I have decided against buying into lazy page loading for now for reasons everybody is probably sick of hearing.