【发布时间】:2020-11-07 12:17:42
【问题描述】:
Angular CLI:9.1.7
我是 Angular 的新手,希望在用户导航到家外的其他组件、登录、注册和忘记密码时显示完全不同的顶部导航栏、侧边栏和页脚方面的帮助。
在仪表板上,显示了新的顶部导航栏和侧边栏,但仍显示旧导航栏<app-header></app-header> 和页脚<app-footer></app-footer>。
当用户不在家、登录、注册和忘记密码页面时,如何让<app-header></app-header>和<app-footer></app-footer>不显示?
app.component.html
<!-- header -->
<app-header></app-header>
<!-- routes will be rendered here -->
<router-outlet></router-outlet>
<!-- footer -->
<app-footer></app-footer>
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'apptitle';
}
app-routing.module.ts
const routes: Routes = [{
path: '',
pathMatch: 'full',
component: HomeComponent
},
{
path: 'login',
component: LoginComponent
},
{
path: 'signup',
component: SignupComponent
},
{
path: 'forgot-password',
component: ForgotPasswordComponent
},
{
path: 'dashboard',
component: DashboardComponent
},
if the user tries to navigate to a page that is not there
{ path: '**',
component: HomeComponent}
];
dashboard.component.html
<app-top-menu-bar></app-top-menu-bar>
<app-side-menu-bar></app-side-menu-bar>
<app-small-footer></app-small-footer>
【问题讨论】:
标签: angular routes navigation angular-components