2017-02-27 52 views
2

下面是什麼都包含在我app.component.html角2動態頁面的頁眉和頁腳

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

但是我的登錄和註冊頁面都通過該模塊提供,而且他們只需要路由器-出口。如何動態地不包括登錄和註冊視圖的lmenu,頁眉和頁腳選擇器?提前致謝。

回答

3
<lmenu *ngIf="isLogin"></lmenu> 
<header *ngIf="isLogin"></header> 
<router-outlet></router-outlet> 
<footer *ngIf="isLogin"></footer> 

只需切換顯示isLoginfalse之間true /隱藏組件

+1

我明白了....對不起新角結構的指令是什麼我失蹤了,謝謝! https://angular.io/docs/ts/latest/guide/structural-directives.html –

1
you could use two times in the terminal: 
- ng generate component header 
- ng generate component footer 

then, in the main app file HTML (app.component.html) you must include the 2 tags: 
<app-header></app-header> 
<app-footer></app-footer> 

this is the first thing to do. 

Then you must populate your templates: 
- header.component.html and the styling in header.component.css 
- footer.component.html and the styling in footer.component.css