我试图根据身份验证更改路由器出口。我的代码如下所示
<div *ngIf="isLoggedIn" class="layout-wrapper layout-2" [ngClass]="{'layout-loading': !initialized}">
<div class="layout-inner">
<app-layout-sidenav></app-layout-sidenav>
<div class="layout-container">
<app-layout-navbar></app-layout-navbar>
<div class="layout-content">
<div class="container-fluid router-transitions flex-grow-1 container-p-y">
<router-outlet></router-outlet>
</div>
<app-layout-footer></app-layout-footer>
</div>
</div>
</div>
</div>
<div class="layout-overlay" (click)="closeSidenav()"></div>
<ng-container *ngIf="!isLoggedIn">
<router-outlet></router-outlet>
</ng-container>在这里,登录屏幕运行良好,但登录后,我无法从经过身份验证的路由加载内容。但是如果我完全刷新页面,它就能工作了。
另外,我试过用插座的名字,但也不起作用。
有人能解决这个问题吗?
提前感谢
发布于 2022-09-05 07:54:55
我认为下面的代码是问题所在,请将其更改为
在此之前:
<ng-container *ngIf="!isLoggedIn">
<router-outlet></router-outlet>
</ng-container>之后:
<router-outlet></router-outlet>如果您想在路由中实现authorization go for canActivate,这是标准的方法!
https://stackoverflow.com/questions/73605902
复制相似问题