Angular 角度-使用命名出口时出现错误:";无法匹配任何路由“;从canActivate guard导航时

Angular 角度-使用命名出口时出现错误:";无法匹配任何路由“;从canActivate guard导航时,angular,Angular,在我的应用程序中,我从CanActivateguard导航到一个登录表单 只要使用一个路由器插座就可以了 但是当尝试使用命名路由器出口在其中显示登录组件时,我得到一个错误: “无法匹配任何路由。URL段:'登录'。” 如何修复它? 以下是我的应用程序中的相关代码: app.component.html: <router-outlet></router-outlet> <router-outlet name="popup"></router-outlet

在我的应用程序中,我从
CanActivate
guard导航到一个登录表单

只要使用一个
路由器插座
就可以了

但是当尝试使用
命名路由器出口
在其中显示登录组件时,我得到一个错误:

“无法匹配任何路由。URL段:'登录'。”

如何修复它?

以下是我的应用程序中的相关代码:

app.component.html:

<router-outlet></router-outlet>
<router-outlet name="popup"></router-outlet>
const routes: Routes = [
  { path: 'login', component: LoginComponent, outlet: 'popup', },

  { path: '', component: MainComponent,
    canActivate : [AuthGuardService],
  },
];
@Injectable()
export class AuthGuardService implements CanActivate {
  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
    return this.loginService
               .isAuthorised()
               .map(res => {
                  ...
                }).catch((err) => {
                  this.router.navigate(['/login']);
                });
  }
}
auth-guard.service.ts:

<router-outlet></router-outlet>
<router-outlet name="popup"></router-outlet>
const routes: Routes = [
  { path: 'login', component: LoginComponent, outlet: 'popup', },

  { path: '', component: MainComponent,
    canActivate : [AuthGuardService],
  },
];
@Injectable()
export class AuthGuardService implements CanActivate {
  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
    return this.loginService
               .isAuthorised()
               .map(res => {
                  ...
                }).catch((err) => {
                  this.router.navigate(['/login']);
                });
  }
}
@Injectable()
导出类AuthGuardService实现CanActivate{
canActivate(路由:ActivatedRouteSnapshot,状态:RouterStateSnashot):可观察{
返回此.login服务
.I授权()
.map(res=>{
...
}).catch((错误)=>{
this.router.navigate(['/login']);
});
}
}
您需要:


this.router.navigate(['/',{outlets:{popup:'login')}]);

现在错误是:
http://localhost:3000/null
-加载资源失败:服务器响应状态为403(禁止)Why“/null”?此问题似乎已解决。非常感谢。您救了我的命!谢谢