File
Metadata
| changeDetection |
ChangeDetectionStrategy.OnPush |
| selector |
cx-page-layout |
| templateUrl |
./page-layout.component.html |
Index
Properties
|
|
|
Inputs
|
|
|
Accessors
|
|
|
|
Readonly
layoutName$
|
Type : Observable<string>
|
Default value : this.section$.pipe(
switchMap((section) => (section ? of(section) : this.templateName$))
)
|
|
|
|
Readonly
pageFoldSlot$
|
Type : Observable<string>
|
Default value : this.templateName$.pipe(
switchMap((templateName) =>
this.pageLayoutService.getPageFoldSlot(templateName)
),
distinctUntilChanged()
)
|
|
|
|
Readonly
section$
|
Type : BehaviorSubject<string>
|
Default value : new BehaviorSubject(undefined)
|
|
|
|
Readonly
slots$
|
Type : Observable<string[]>
|
Default value : this.section$.pipe(
switchMap((section) => this.pageLayoutService.getSlots(section))
)
|
|
|
|
Readonly
templateName$
|
Type : Observable<string>
|
Default value : this.pageLayoutService.templateName$
|
|
|
Accessors
|
section
|
setsection(value: string)
|
|
|
Parameters :
| Name |
Type |
Optional |
| value |
string
|
No
|
|
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { BehaviorSubject, Observable, of } from 'rxjs';
import { distinctUntilChanged, switchMap } from 'rxjs/operators';
import { PageLayoutService } from './page-layout.service';
@Component({
selector: 'cx-page-layout',
templateUrl: './page-layout.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class PageLayoutComponent {
@Input() set section(value: string) {
this.section$.next(value);
}
readonly section$: BehaviorSubject<string> = new BehaviorSubject(undefined);
readonly templateName$: Observable<string> =
this.pageLayoutService.templateName$;
readonly layoutName$: Observable<string> = this.section$.pipe(
switchMap((section) => (section ? of(section) : this.templateName$))
);
readonly slots$: Observable<string[]> = this.section$.pipe(
switchMap((section) => this.pageLayoutService.getSlots(section))
);
readonly pageFoldSlot$: Observable<string> = this.templateName$.pipe(
switchMap((templateName) =>
this.pageLayoutService.getPageFoldSlot(templateName)
),
distinctUntilChanged()
);
constructor(protected pageLayoutService: PageLayoutService) {}
}
<ng-template
[cxPageTemplateStyle]="layoutName$ | async"
[cxOutlet]="layoutName$ | async"
[cxOutletContext]="{
templateName$: templateName$,
slots$: slots$,
section$: section$
}"
>
<ng-content></ng-content>
<cx-page-slot
*ngFor="let slot of slots$ | async"
[position]="slot"
[isPageFold]="slot === (pageFoldSlot$ | async)"
></cx-page-slot>
</ng-template>
Legend
Html element with directive