-
Notifications
You must be signed in to change notification settings - Fork 1
Upgrade Notes
This page contains the notes for upgrades
-
ionic serve
doesn't work for now. Useng serve
. - ionic v4 depends on angular and rxjs 6.x.
- Installed ionic cli (rc)
npm i -g ionic@rc
- Created a new project
ionic start v4-ion-meetups tabs --type=angular
The following steps copy listed directories from v3 project to listed destinations in v4 project.
- Copied
/src/pages
to/src/app/pages
- Copied
/src/models
to/src/app/models
- Copied
/src/providers
to/src/app/providers
. - Copied
/src/utils
to/src/app/utils
.
Now getting error Can't resolve module ionic-angular
. Fixing this.
-
From all the individual pages' modules, replaced
IonicPageModule
andIonicPageModule.forRoot...
withIonicModule
. -
Replaced
ionic-angular
with@ionic/angular
. -
There's no
ViewController
in v4. If you're using it for modals, replace it withModalController
from@ionic/angular
. -
ActionSheetController#create
now returns a promise for the action sheet, instead of action sheet itself.
Upgrading routes:
- Getting the container tabs page to work first
- Added a routes definition with only Tabs page, and blank redirect routes to start with. Also imported the routes in
TabsPageModule
.
const routes: Routes = [
{
path: 'tabs',
component: TabsPage
},
{
path: '',
redirectTo: '/tabs',
pathMatch: 'full'
}
];
Getting error that root is not a known property of ion-tab
. Expected since ion-tab
has a different API/usage in v4.
- Renamed
tabIcon
toicon
forion-tab
element. - Replaced
[root]...
withhref=
attribute. - Renamed
tabTitle
tolabel
. -
ion-tab
also needs a child elemention-router-outlet
. This new element takes aname
attribute which helps in specifying which components go in which tab while writing routes.
This gets the tab page working, but obviously shows blank tab content.
** Getting about page loading **
-
In
about.module.ts
, added entry component withAboutPage
component. Also, added aRouterModule.forChild
import to the module with blank path,AboutPage
component andabout
outlet. This outlet tells this route which router outlet to target when loading. Since we're lazy loading, we need to specify this outlet in both - tabs module and about page module. -
In 'tabs.module.ts', add a new child route for main
tabs
route:
{
path: 'tabs',
component: TabsPage,
children: [
{
path: 'about',
outlet: 'about',
loadChildren: '../about/about.module#AboutPageModule'
}
]
},
This allows lazy loading AboutPage
component into ion-router-outlet
with the name about
inside tabs.html
.