如何隐藏首页的页脚组件?

时间:2020-04-07 17:02:38

标签: angular routes components show-hide

这是我的app.component.html文件:

<app-header></app-header>
<router-outlet></router-outlet>
<app-footer></app-footer>

但是我要做的是隐藏/home路由中的页脚组件。我怎样才能做到这一点? (请让我知道是否需要添加更多代码或信息?)

1 个答案:

答案 0 :(得分: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>

因此,如果您位于home组件中,则不会呈现页脚组件。

相关问题