I get this error, when I want to open the detail view from a component in my list. I'm working with Ionic 4.
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'algodetail'
I found many topics with this error, but didn't find a solution there. I'm not sure, perhaps just a misspelling?
The List view:
<ion-content padding>
<ion-card *ngFor="let algo of algoList | async" routerLink="/algodetail/{{algo.id}}">
<ion-card-header>
{{ algo.title }}
</ion-card-header>
</ion-card>
</ion-content>
Routes in app-routing.module.ts:
const routes: Routes = [
{ path: '', loadChildren: './tabs/tabs.module#TabsPageModule' },
{ path: 'algodetail/:id', loadChildren: './algodetail/algodetail.module#AlgodetailPageModule' }
];
algodetail.page.ts:
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { Algo } from '../models/algo';
import { FirestoreService } from '../services/data/firestore.service';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-algodetail',
templateUrl: './algodetail.page.html',
styleUrls: ['./algodetail.page.scss'],
})
export class AlgodetailPage implements OnInit {
public algo: Observable<Algo>
constructor(private firestoreService: FirestoreService, private route: ActivatedRoute ) {
}
ngOnInit() {
}
}
algodetail.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { AlgodetailPage } from './algodetail.page';
const routes: Routes = [
{
path: '',
component: AlgodetailPage
}
];
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild(routes)
],
declarations: [AlgodetailPage]
})
export class AlgodetailPageModule {}
My Filesystem
Looking at the error message, it appears that the id is not set. If you turn on enableTracing on the route, does it give you any more information? Can you confirm that the id value is indeed being set for the route?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With