0

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??

  • Use `domino` to provide a mock for `window` – David Mar 16 '21 at 15:47
  • have created a windowservice to handle window object throughout the project. But trading view libraries contains multiple window objects in .min (minified) scripts. How to handle that? – NiKhil Kutewalla Mar 17 '21 at 09:15

1 Answers1

1

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

server.ts

//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
David
  • 33,444
  • 11
  • 80
  • 118