mirror of
https://github.com/mempool/mempool.git
synced 2026-08-13 12:33:11 +02:00
20 lines
576 B
TypeScript
20 lines
576 B
TypeScript
import { Directive, TemplateRef, ViewContainerRef, Inject, PLATFORM_ID } from '@angular/core';
|
|
import { isPlatformServer } from '@angular/common';
|
|
|
|
@Directive({
|
|
selector: '[serverOnly]',
|
|
standalone: false,
|
|
})
|
|
export class ServerOnlyDirective {
|
|
constructor(
|
|
private templateRef: TemplateRef<any>,
|
|
private viewContainer: ViewContainerRef,
|
|
@Inject(PLATFORM_ID) private platformId: object
|
|
) {
|
|
if (isPlatformServer(this.platformId)) {
|
|
this.viewContainer.createEmbeddedView(this.templateRef);
|
|
} else {
|
|
this.viewContainer.clear();
|
|
}
|
|
}
|
|
}
|