The default path in app-routing.module.ts
does not seem to be working in my app.
Here is the start of the file:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { IsReadyGuard } from './is-ready.guard';
import { LoggedInGuard } from './logged-in.guard';
const routes: Routes = [
{ path: '', redirectTo: '/login', pathMatch: 'full' },
{ path: 'login', canActivate:[IsReadyGuard], loadChildren: './pages/login/login.module#LoginPageModule' },
When I navigate to localhost:8100/login, I see my login page no problem.
If I simply go to localhost:8100, I just get a blank page. (I removed the canActivate guard on /login but no help)
So I tried a patch by adding a condition in app.component.ts after platform.ready()
if (window.location.pathname === "/"){
this.router.navigateByUrl('/login');
}
This works BUT it seems to stack /login as the second page in the navigation stack. The back button (on browser and android) brings me back to a blank page so I’m guessing I’m seeing app.component.ts without a selected path?
Any idea why my default path is not working?
Otherwise, does anyone know what’s the latest and greatest method of managing the navigation stack in Ionic 4? Is there a way I can specify that I want /login to be first (root) in the navigation stack?
Here’s my ionic info:
Ionic:
ionic (Ionic CLI) : 4.8.0 (C:\Users\lucch\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.16
@angular-devkit/build-angular : 0.12.2
@angular-devkit/schematics : 7.0.6
@angular/cli : 7.0.6
@ionic/angular-toolkit : 1.2.0
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.4
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.2, (and 5 other plugins)
System:
NodeJS : v11.4.0 (C:\Program Files\nodejs\node.exe)
npm : 6.4.1
OS : Windows 10
EDIT: I started a new project and the default path does indeed redirect to /home. I started copying files from my project to the new setup and the redirect to login works but my project is huge and if I copy everything, the redirect to login stops working. What could interfere with the default path routing?