这是我的app.component.html
文件:
<app-header></app-header>
<router-outlet></router-outlet>
<app-footer></app-footer>
但是我要做的是隐藏/home
路由中的页脚组件。我怎样才能做到这一点? (请让我知道是否需要添加更多代码或信息?)
答案 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组件中,则不会呈现页脚组件。