[Fixed] Integrate Trading view with Angular 10 universal SSR


Hi I have integrated trading view libraries for Angular 10 client side rendering. Recently I want to do SEO for my website so had implement trading view in Angular 10 universal.

Here main issue is when I load trading view first time it loads perfectly. But when i load for the second time it gives "window is not defined" errorintegrated console error

I have imported datafeeds in index.html index.html

please check my ts.app.config ts.app.config

what more do i have to add to make it work on angular 10 universal??


Like I said in my comment, you can try using domino to provide a mock for window object, especially for 3rd party libs


//imports ...

const domino = require('domino');
const win = domino.createWindow('/path/to/your/project/dist/client/index.html');
global['window'] = win;
global['document'] = win.document;
global['navigator'] = win.navigator;

//start express server as usual

Leave a Reply

(*) Required, Your email will not be published