這是我的work:
https://stackblitz.com/edit/angular-nsosqn
我已經為 /admin 設定了guard(詳情請參看/admin/admin.guard.ts),
現在已經成功地將/admin 的request forward 到/login/;
問題是如果request 是 /admin/def,它就不懂forward 了, 以下是我的/admin/admin-routing.module.ts 內容:
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 { }
請問是什麼問題呢?