Exclude echarts from server-side rendering

This commit is contained in:
Mononaut
2023-10-18 21:12:51 +00:00
parent e6fb93140c
commit a2b9b0c89d
24 changed files with 48 additions and 24 deletions

View File

@@ -0,0 +1,19 @@
import { Directive, TemplateRef, ViewContainerRef, Inject, PLATFORM_ID } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
@Directive({
selector: '[browserOnly]'
})
export class BrowserOnlyDirective {
constructor(
private templateRef: TemplateRef<any>,
private viewContainer: ViewContainerRef,
@Inject(PLATFORM_ID) private platformId: Object
) {
if (isPlatformBrowser(this.platformId)) {
this.viewContainer.createEmbeddedView(this.templateRef);
} else {
this.viewContainer.clear();
}
}
}