Angular Universal with angular2-tinymce

Viewed 339

I'm having trouble getting tinymce plugin to work with angular universal. I have tried to use "isBrowser" to get the editor to render but I still get this error:

Call to Node module failed with error: Prerendering failed because of error: ReferenceError: navigator is not defined at C:\MyProject\node_modules\tinymce\tinymce.min.js:6:21750

Here is the relevant code I'm using in app.module:

import { TinymceModule } from 'angular2-tinymce';
import { isBrowser, isNode } from 'angular2-universal'
import { UniversalModule } from 'angular2-universal';
...

let imports = [
    UniversalModule, 
    FormsModule,
    ReactiveFormsModule,
...
]

if (isBrowser) {
    imports.push(TinymceModule.withConfig({}));
}


@NgModule({
    bootstrap: [AppComponent],
    declarations: [ ...//declarations listed here
    ],
    providers: [ ... //providers listed here
    ],
    imports: imports
})
export class AppModule {
}

The error gets thrown when I try to import the tinymce module. if I remove the line

if (isBrowser) { imports.push(TinymceModule.withConfig({})); }

the project will compile and run. I'm sure this has to do with the fact that the module uses the window object and that's why I tried to implement the 'isBrowser' functionality but I'm still not doing it correctly. Any help is much appreciated.

0 Answers
Related