Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Routing works wrong with included routes #449

@launcelot66

Description

@launcelot66

package.json:

{
  "dependencies": {
    "@angular/animations": "~11.1.1",
    "@angular/cdk": "^11.1.1",
    "@angular/common": "~11.1.1",
    "@angular/compiler": "~11.1.1",
    "@angular/core": "~11.1.1",
    "@angular/forms": "~11.1.1",
    "@angular/material": "^11.1.1",
    "@angular/platform-browser": "~11.1.1",
    "@angular/platform-browser-dynamic": "~11.1.1",
    "@angular/router": "~11.1.1",
    "jwt-decode": "^3.1.2",
    "rxjs": "~6.6.0",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1101.1",
    "@angular/cli": "~11.1.1",
    "@angular/compiler-cli": "~11.1.1",
    "@types/jasmine": "~3.6.0",
    "@types/node": "^14.14.20",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.2.3",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~9.1.1",
    "tslint": "~6.1.0",
    "typescript": "~4.0.2"
  }
}

main routes (app.routing.ts):

import {RouterModule, Routes} from '@angular/router';
import {NotFoundComponent} from './components/not-found/not-found.component';

const routes: Routes = [{
  path: '',
  redirectTo: 'auth',
  pathMatch: 'full'
}, {
  path: 'auth',
  loadChildren: () => import('./modules/auth/auth.module').then(m => m.AuthModule)
}, {
  path: '**',
  component: NotFoundComponent
}];

export const ROUTING = RouterModule.forRoot(routes);

auth.module.ts:

import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {AuthLayoutComponent} from './layout/auth-layout.component';
import {AuthLayoutModule} from './layout/auth-layout.module';

const routes: Routes = [{
  path: '',
  redirectTo: '/auth/login',
  pathMatch: 'full'
}, {
  path: 'login',
  component: AuthLayoutComponent,
  loadChildren: () => import('./login/login.module').then(m => m.LoginModule)
}, {
  path: 'restore',
  component: AuthLayoutComponent,
  loadChildren: () => import('./restore/restore.module').then(m => m.RestoreModule)
}];

const ROUTING = RouterModule.forChild(routes);

@NgModule({
  imports: [
    ROUTING,
    AuthLayoutModule
  ]
})
export class AuthModule {}

so from now i can go to http://localhost:4200/login and it works (but must render NotFoundComponent)
if add "auth/" at begin of "login" and/or "restore" path - will works correct, but this isn't normal

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions