No routes found to match - Issue encountered in Ionic 5 Angular project

I have a total of 15 pages within my project and I am looking to incorporate a page with 2 tabs. To make this happen, I have created a folder labeled tabs inside the existing app directory.

Inside the tabs folder, there are 3 specific pages - 1. project view 2. project tasks 3. project conversations

I followed the instructions in the documentation by adding 2 and 3 into the project view, but encountered an error:

Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'projectview/tab1'

Error: Cannot match any routes. URL Segment: 'projectview/tab1'

Below is the code snippet from projectview-routing.module.ts:

    import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { ProjectviewPage } from './projectview.page';

    
const routes: Routes = [
  {
    path:'projectview',
    component: ProjectviewPage,
    children:[
     {path: 'tab1', 
     //loadChildren:'./../projecttasks/projecttasks.module#ProjecttasksPageModule'
     loadChildren: () => import('../projecttasks/projecttasks.module').then( m => m.ProjecttasksPageModule)
    },
     {path: 'tab2’, 
     //loadChildren:'./../projectconversations/projectconversations.module#ProjectconversationsPageModule'
     loadChildren: () => import('../projectconversations/projectconversations.module').then( m => m.ProjectconversationsPageModule)
    },
    {
      path: '',
      redirectTo: '/projectview/tab1',
      pathMatch: 'full”
    }
    ]
  },
  {
    path:'',
    redirectTo:'/projectview/tab1',
    pathMatch: 'full"
  }
  
];




@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})
export class ProjectviewPageRoutingModule {}

This is the content provided in projectview.page.html:

<ion-tabs>
  <ion-tab-bar slot="bottom">
    <ion-tab-button tab="tab1">
      <ion-icon name="flash"></ion-icon>
      <ion-label>Tab One</ion-label>
    </ion-tab-button>
    <ion-tab-button tab="tab2">
      <ion-icon name="apps"></ion-icon>
      <ion-label>Tab Two</ion-label>
    </ion-tab-button>
  </ion-tab-bar>
</ion-tabs>

The routes for the tab pages have also been commented out in app-routing.module.ts:

  // {
  //   path: 'projecttasks',
  //   loadChildren: () => import('./tabs/projecttasks/projecttasks.module').then( m => m.ProjecttasksPageModule)
  // },
  // {
  //   path: 'projectconversations',
  //   loadChildren: () => import('./tabs/projectconversations/projectconversations.module').then( m => m.ProjectconversationsPageModule)
  // }

It seems like something is missing, what could it be?

Edit 1

I even attempted using paths like this in pageview.module.ts, however, it did not resolve the issue either:

 {path: 'tab1', 
 //loadChildren:'./../projecttasks/projecttasks.module#ProjecttasksPageModule'
 loadChildren: () => import('../projecttasks/projecttasks.module').then( m => m.ProjecttasksPageModule)
},
 {path: 'tab2', 
 //loadChildren:'./../projectconversations/projectconversations.module#ProjectconversationsPageModule'
 loadChildren: () => import('../projectconversations/projectconversations.module').then( m => m.ProjectconversationsPageModule)
},

Answer №1

To fix the issue, simply delete the forward slash from the pathway

path:'',redirectTo:'projectview/tab1'

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Hold on for the completion of the promise inside the external function

Currently, I am working on a project using Ionic2 + Laravel. My goal is to create an "interceptor" that will automatically add the JWT token for authentication from LocalStorage to all of my Http requests. To achieve this, I have created a Service with ...

How to send a variable to Firestore query in an Angular application

I'm attempting to retrieve data from a schedule collection based on a field matching the user's id. However, I'm encountering an issue with the error message: "Function Query.where() requires a valid third argument, but it was undefined." ...

An error occurs when implementing the RxJS partition operator in combination with Angular

Extracting data in ngOnInit hook: ngOnInit(): void { var routeParameters = zip( this._route.parent.paramMap, this._route.paramMap ).pipe( map(([parentMap, currentMap]) => ({ customerID: parentMap.get('id'), siteID: currentMap. ...

Tips for resolving SyntaxError: Unable to utilize import when integrating Magic with NextJS in a Typescript configuration

Looking to integrate Magic into NextJS using TypeScript. Following a guide that uses JavaScript instead of TypeScript: https://github.com/magiclabs/example-nextjs Encountering an issue when trying to import Magic as shown below: import { Magic } from &qu ...

Having trouble making Angular Dynamic Nested FormArrays function properly

I'm currently working on creating an array of books with multiple authors that can be added or removed dynamically. As I delve into learning Angular, I've encountered the necessity of having a nested array within another array in my project. Th ...

What is the best way to iterate through an array of objects in Typescript, filter them by a specific property, and then return a Component with custom props

Learning React and Typescript can be challenging, especially when trying to render components with specific data. In my case, I am working with an array of cars and their respective years. The goal is to group these cars by year, but I'm running into ...

Displaying Asynchronous Error Messages with the toast.error Function in React

I have successfully integrated an asynchronous login thunk with error handling. While the success message displays correctly, the error message is not appearing as expected. export const loginThunk = createAsyncThunk( 'login', async (credenti ...

Personalize your Client-Id for Paypal

Currently integrating PayPal's Smart Payment Buttons into my Angular project. The index.html file contains the following script: <script src="https://www.paypal.com/sdk/js?client-id=MY_CLIENT_ID"> </script> I am working on developi ...

Guide on integrating third party jquery plugin with Angular 7

Hey there! I've been working on integrating a third-party jQuery plugin into my Angular 7 app. Here's what I've done so far: I added the file locations in angular.json like this: "scripts": [ "node_modules/jquery/dist/jquery.m ...

Transforming Observable into a Promise

Is it considered a best practice to convert an observable object to a promise, given that observables can be used in most scenarios instead of promises? I recently started learning Angular and came across the following code snippet in a new project using ...

Trouble accessing hyperlink with puppeteer - Thingiverse

Seeking assistance in automating the process of downloading multiple files from Thingiverse. Having trouble locating and clicking on the necessary link for download after selecting a random object. Any help or tips would be greatly appreciated! I have tri ...

Creating a dynamic table with columns of fixed width in Angular on the fly

I am struggling to create a data table with fixed column widths (20% each). I have incorporated div elements in my table structure to enable dynamic row creation using Angular, but this has caused some design issues. My goal is for all rows to occupy 100% ...

What makes it permissible to use `declare const foo = 3` in TypeScript?

As I was working on creating a TypeScript declaration file, I discovered that it is permissible to declare a constant and assign a value to it. declare const foo = 1; // This is considered valid declare const bar = 'b'; // This is al ...

Utilize Moment to retrieve the weekend dates

Currently tackling a date-related issue and feeling stuck. Is it feasible to extract weekends from an array of dates using Moment.js instead of the getDay() method? I'm a beginner in JavaScript. ...

"Utilize the routerLink feature in Angular to pass covert parameters or hidden data

Here's a router link example: <button class="take-a-tour-btn" [routerLink]="['/dashboard', {'showTour':'show'}]"> I am trying to pass the parameter showTour, but when I do this, the parameter is visible in the URL ...

The namespace does not contain any exported member

Every time I attempt to code this in TypeScript, an error pops up stating The namespace Bar does not have a member named Qux exported. What could possibly be causing this and how can I resolve it? class Foo {} namespace Bar { export const Qux = Foo ...

HMR not functioning in Vite React TypeScript monorepo

I am working with a Vite/React/Typescript/Yarn monorepo that consists of two applications and some shared components. However, I am facing issues with setting up Hot Module Replacement (HMR) while running vite dev. You can find an example repository here: ...

Centered Fixed Upward Scrolling Div

Currently facing a challenge with my project involving a chat interface created in Angular. I am struggling with the CSS styling as the chat starts at the top and scrolls downward off-screen as the conversation progresses. Although I can scroll along with ...

The issue with Ionic 2 and Angular 2 is that the http Headers are not getting included in the request

I'm currently working with the latest beta release of Ionic and I've encountered an issue with sending headers along with an HTTP POST request to my API server. The code snippet I used is as follows: ** Ionic version - Beta-8 & Angular version -r ...

Combine two Observable arrays into a single array and showcase their contents using ngFor within an Ionic 3 application

In my Ionic 3 project, I am fetching two arrays through API calls. My goal is to display the data from both arrays in the same line like this: [item1.1] [item2.1] [item1.2] [item2.2] [item1.3] [item2.3] Instead of displaying them like this: [item1.1] ...