Reputation: 93
I just updated from ionic 4 beta 17 to 18 and a breaking change in <ion-item>
and <ion-button>
was introduced. The href was replaced with routerLink.
I added this to my code and now the routing doesn't work anymore. Most of the time the compiler throws errors and says, that routerLink does not exist in ion-item.
What did i do wrong? Or is it angular?
"@ionic/angular": "~4.0.0-beta.18",
"@ionic/core": "~4.0.0-beta.18",
"@angular/core": "^7.1.3",
"@angular/router": "~7.1.3",
<ion-item text-wrap class="nav-item" routerDirection="forward"
[routerLink]="p.url"
*ngFor="let p of listOfPages; let i = index"
[class.active-item]="checkActivePath(p.url)"
[class.last-item]="i === (listOfPages.length - 1)">
<ion-label class="nav-label">
<ion-img [src]="p.icon" class="nav-icon"></ion-img>
<div class="text-block">
{{ p.title }}
</div>
</ion-label>
</ion-item>
Upvotes: 1
Views: 12544
Reputation: 93
So this is what finally worked for me:
In every nested module I used
const routes: Routes = [{
path: '',
component: AboutUsPage
}];
I imported RouterModule.forChild(routes)
there aswell.
/
before the path. Like '/home'
{path: 'about-us/:id', component: AboutUsPage},
.Upvotes: 3
Reputation: 1764
Import RouterModule
in the module file of the module where the template is (the module where routerLink is used):
import { RouterModule } from '@angular/router';
@NgModule({
imports: [
// ...
RouterModule,
]
Upvotes: 6
Reputation: 3878
Maybe the missing " after routerDirection?
routerDirection="forward
EDIT: when you are using a Ionic component, you should use href. RouterLink is for non-Ionic components.
Upvotes: 0