我有一个导航栏,其中包含必须选择的不同组件。配置文件组件确实打开,但是“我的最爱”按钮未显示该组件的任何内容。
这是导航栏中的代码:
<form class="form-inline my-2 my-lg-0">
<ul class="nav navbar-nav navbar-right">
<li *ngIf="authService.loggedIn()" [routerLinkActive]="['active']" [routerLinkActiveOptions] = "{exact:true}"><a class="nav-link" [routerLink]= "['/favorites']">My favorites</a></li>
<li *ngIf="authService.loggedIn()" [routerLinkActive]="['active']" [routerLinkActiveOptions] = "{exact:true}"><a class="nav-link" [routerLink]= "['/dashboard']">Dashboard</a> </li>
<li *ngIf="authService.loggedIn()" [routerLinkActive]="['active']" [routerLinkActiveOptions] = "{exact:true}"><a class="nav-link" [routerLink]= "['/profile']">Profile</a></li>
<li *ngIf="!authService.loggedIn()" [routerLinkActive]="['active']" [routerLinkActiveOptions] = "{exact:true}"><a class="nav-link" [routerLink]= "['/login']">Login</a></li>
<li *ngIf="!authService.loggedIn()" [routerLinkActive]="['active']" [routerLinkActiveOptions] = "{exact:true}"> <a class="nav-link"[routerLink]= "['/register']">Register</a></li>
<li><a class="nav-link" (click)="onLogOutClick()" href="#">Logout</a></li>
</ul>
</form>
我的app.module.ts中有以下路线:
const appRoutes: Routes = [
{path: '', component: HomeComponent},
{path: 'register', component: RegisterComponent},
{path: 'login', component: LoginComponent},
{path: 'dashboard', component: DashboardComponent, canActivate: [AuthGuard]},
{path: 'profile', component: ProfileComponent, canActivate: [AuthGuard]},
{path: 'favorites', component: FavoritesComponent, canActivate: [AuthGuard]}
]
如有必要,我可以为您提供更多代码。
答案 0 :(得分:0)
检查您的收藏夹组件是否包含在AppModule.ts文件中。