'How to import file conditionally @ckeditor/ckeditor5-angular in SSR
I'm stuck in Angular Universal/SSR @ckeditor/ckeditor5-angular. When I import ClassicEditor
import * as ClassicEditor from '@ckeditor/ckeditor5-build-classic';
then receive error window is undefined. I'm tried many options but can't solve these issues. Now I want to import ClassicEditor only for the browser platform. But issues are
this.isBrowser = isPlatformBrowser(this.platformId);
isBowser value receive true|false after initialize components constructor. Anyone help me how to import a file conditionally like below:
if(isBowser){
import * as ClassicEditor from '@ckeditor/ckeditor5-build-classic';
}
Solution 1:[1]
if(isPlatformBrowser(this.platformId)){
import('@ckeditor/ckeditor5-build-classic').then(i => {
this.ClassicEditor = i.default;
};
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sunday David |
