0
我有共同的標題組件和頁腳組件。頭部組件在模型彈出窗口中有登錄表單腳本。當用戶點擊這些組件中的添加評論按鈕時,我想顯示登錄模型彈出如HomepageComponent
,CountryDetailComponent
,ExploreListComponent
& DetailedPageComponent
。我的代碼在這裏。如何只顯示一個登錄模式彈出所有?如何顯示來自其他組件的登錄表單?
APP-routing.module.ts
const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: 'home', component: HomepageComponent,},
{ path: ':city', component: CountryDetailComponent },
{ path: ':city/:subscategory', component: ExploreListComponent },
{ path: ':city/:subscategory/:singleitem', component: DetailedPageComponent },
];
app.component.ts
import { Component } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'my-app',
template: `
<app-header></app-header>
<router-outlet></router-outlet>
<app-footer></app-footer>
`,
})
export class AppComponent { }
header.component.ts
import { Component,Renderer } from '@angular/core';
import { Title } from '@angular/platform-browser';
@Component({
moduleId: module.id,
selector: 'app-header',
template: `header.component.html`,
})
export class HeaderComponent {
constructor(title: Title) { }
}
header.component.html
<div>
/* header menu here */
</div>
<div>
/*login form here */
</div>
你能否用我的代碼創建plunkr? – vel
請問您是否可以使用您現有的代碼爲我創建一個調度程序,我將根據此改變此問題。 @vel –
或者我們可以爲登錄創建單獨的組件嗎? – vel