@@ -0,0 +1,23 @@
|
||||
import { Injectable, TemplateRef, signal } from '@angular/core';
|
||||
|
||||
/**
|
||||
* Bridges per-page action controls into the shared system header rendered by
|
||||
* UserPortalComponent. A child route cannot project content into its parent
|
||||
* shell through <router-outlet>, so pages register a TemplateRef here and the
|
||||
* shell renders it in the header's right-side actions slot.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class PageHeaderService {
|
||||
/** The current page's action controls, or null when the page has none. */
|
||||
readonly actions = signal<TemplateRef<unknown> | null>(null);
|
||||
|
||||
/** Called by a page (typically in ngAfterViewInit) to publish its actions. */
|
||||
public setActions(actionsTemplate: TemplateRef<unknown> | null): void {
|
||||
this.actions.set(actionsTemplate);
|
||||
}
|
||||
|
||||
/** Called by a page in ngOnDestroy so its actions do not leak to the next page. */
|
||||
public clear(): void {
|
||||
this.actions.set(null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user