【问题标题】:How to hidden footer component for home page?如何隐藏主页的页脚组件?
【发布时间】:2020-07-19 23:06:39
【问题描述】:
这是我的app.component.html 文件:
<app-header></app-header>
<router-outlet></router-outlet>
<app-footer></app-footer>
但我想做的是我想在/home 路由中隐藏页脚组件。我怎样才能做到这一点? (如果需要添加更多代码或信息,请告诉我?)
【问题讨论】:
标签:
angular
routes
components
show-hide
【解决方案1】:
你可以从路径知道你在home组件中:
In app.component.ts
page: string;
//See what is the current page from the path
this.page = this.route.parent.snapshot.url[0].path;
so in app.component.html
<app-header></app-header>
<router-outlet></router-outlet>
<app-footer *ngIf="page != 'home" ></app-footer>
因此,如果您在主组件中,则不会呈现页脚组件。