我有如下的路线配置:
const routes: Routes = [
{ path: '', redirectTo: '/login', pathMatch: 'full' },
{ path: 'login', component: LoginComponent },
{ path: 'dashboard', component: DashboardComponent }
];
Run Code Online (Sandbox Code Playgroud)
现在,如果有人想访问像http://localhost:4200/xyzxyz这样的 url ,那么我会收到此错误
未捕获(承诺):错误:无法匹配任何路由。URL 段:'xyz'
但我想在上述情况下重定向到登录页面。
知道我怎样才能实现这一目标吗?