Open waseem-isaac-BBN opened 4 years ago
Same Error in Angular 8 SSR when using the modal component that calls the ngx-bootstrap-utils.js who contain the function responsible of poping the error.
function _guessBsVersion() { if (typeof document === 'undefined') { return null; } /** @type {?} */ const spanEl = document.createElement('span'); spanEl.innerText = 'test bs version'; document.body.appendChild(spanEl); spanEl.classList.add('d-none'); /** @type {?} */ const rect = spanEl.getBoundingClientRect(); document.body.removeChild(spanEl); if (!rect) { return 'bs3'; } return rect.top === 0 ? 'bs4' : 'bs3'; }
THE ERROR :
ERROR TypeError: spanEl.getBoundingClientRect is not a function at _guessBsVersion (/home/app/dist/test/server/main.js:12:89) at isBs3 (/home//app/dist/test/main.js:45:1) at ModalBackdropComponent.set isShown [as isShown] (/home/app/dist/test/main.js:458:1) at ModalBackdropComponent.ngOnInit
I have an alternative solution, once you call the bsModalService to show the modal component, please wrap the function inside the condition of isPlatformBrowser(appId) true. You can use it with inject DOCUMENT and PLATFORM_ID. @waseem-isaac-BBN
This Error appears on the console with the Modal while serving SSR . Maybe there's a bug in
ModalBackdropComponent.set [as isShown]
Isn't ngx-bootstrap modal has support Server Side Rendering ?
Iam using :
"@angular: 8.2.x"
"@nguniversal : 8.2.x"
"ngx-bootstrap": "5.2.0"