Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 11 Renderer2 issue? #91

Open
labago opened this issue May 20, 2021 · 4 comments
Open

Angular 11 Renderer2 issue? #91

labago opened this issue May 20, 2021 · 4 comments

Comments

@labago
Copy link

labago commented May 20, 2021

I can't seem to get this to work in Angular 11, I have a very basic setup using the instructions in the README but I get the following errors:

image
image

Any ideas?

@FeliipeAC
Copy link

I manually changed the declarations from Renderer to Renderer2 and this error is gone, but the second error is still

@rramsey
Copy link

rramsey commented Sep 6, 2021

Angular 12.2.4 w/ ngx-lightbox 2.0.0 here. Changing the import in the lightbox.component.ts and lightbox-overlat.component.ts files worked for me. BUT you have to also change the constructor as well so _rendererRef is an instance of Renderer2.

    import { AfterViewInit, ElementRef, OnDestroy, OnInit, Renderer2 } from '@angular/core';
    ...
    constructor(_elemRef: ElementRef, _rendererRef: Renderer2, _lightboxEvent: LightboxEvent, _lightboxElem: ElementRef, _lightboxWindowRef: LightboxWindowRef, _sanitizer: DomSanitizer, _documentRef: Document);

One I did that, everything worked fine. There could still be an issue with the Renderer methods/properties not matching Renderer2 100%, but at least with a bare minimum app, it compiled.

Renderer2 is supposed to be available with Angular 8, the minimum for ngx-lightbox 2.0.0, so in theory that is all that would need to change. I'd put in a PR for this since it looks like such an easy and simple fix, but I'm not sure what else would break. Maybe I will anyway. The worst that can happen is the devs decline the PR.

Hope that helps.

@whizyrel
Copy link

whizyrel commented Oct 3, 2021

ve you made this PR yet? I am having this issue too

I have the issue you described when I install just 2.0.0, otherwise this error in the image below.

Screenshot from 2021-10-03 15-03-05

For now, I having to remove lightbox because I cannot wait

@whizyrel
Copy link

whizyrel commented Oct 3, 2021

Apparently, what started the issue for me was the latest version 2.5.0, going back to 2.4.1 returned ngx-lightbox to the desired state for me though there was the ".../src/app/app.module.ts depends on 'ngx-lightbox'. CommonJS or AMD dependencies can cause optimization bailouts" warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants