Here is my work.
I set up a guard to forward the request URI /admin to /login, you may refer /admin/admin.guard.ts for detail.
It works fine. However, when the request URI is /admin/abc, it does not work.
The following is the /admin/admin-routing.module.ts content:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AdminComponent } from './admin.component';
import { AdminGuard } from './admin.guard';
const routes: Routes = [
{
path: 'admin',
canActivate: [AdminGuard],
component: AdminComponent,
children: [
{
path: '',
redirectTo: 'admin',
pathMatch: 'full'
},
{
path: '**',
redirectTo: 'admin',
pathMatch: 'full'
}
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class AdminRoutingModule { }
How can I fix the problem?