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

Universal issue #12

Open
Ismaestro opened this issue Apr 17, 2019 · 12 comments
Open

Universal issue #12

Ismaestro opened this issue Apr 17, 2019 · 12 comments

Comments

@Ismaestro
Copy link

Hello again 😄!

I have this error while serving the app built with Angular Universal:

Error: StaticInjectorError(AppServerModule)[ProgressiveImageDirective -> InjectionToken WindowToken]: 
  StaticInjectorError(Platform: core)[ProgressiveImageDirective -> InjectionToken WindowToken]: 
    NullInjectorError: No provider for InjectionToken WindowToken!

any ideas?? I'm importing the last version in beta (7).

@Ismaestro
Copy link
Author

Ismaestro commented Apr 17, 2019

Fixed with this:

  isBrowser: boolean;

  constructor(@Inject(PLATFORM_ID) private platformId: Object) {
    if (isPlatformBrowser(this.platformId)) {
      this.isBrowser = true;
    }
  }
  <ng-container *ngIf="isBrowser">
    <ngx-progressive-image-loader
      [filter]="'blur(3px) drop-shadow(0 0 0.75rem crimson)'"
      [placeholderImageSrc]="hero.avatarBlurredUrl">
      <img (click)="seeHeroDetails(hero)" src="{{hero.avatarUrl}}" alt="" ngxProgressiveImage />
    </ngx-progressive-image-loader>
  </ng-container>

Maybe you should add some documentation on this or a demo...
Finally working here :)

@maxisam
Copy link
Owner

maxisam commented Apr 18, 2019

I thought I had a demo? but thanks! This is still work in process. I will try to make it better and welcome to make a pull request.

@maxisam
Copy link
Owner

maxisam commented Apr 18, 2019

Could you try 4.0.0-beta.9? you don't need <ng-container *ngIf="isBrowser"> anymore in theory.

@maxisam maxisam reopened this Apr 18, 2019
@Ismaestro
Copy link
Author

Done, and yes, it's working as expected.

Thanks!!

@maxisam
Copy link
Owner

maxisam commented Apr 18, 2019

Thank you! Btw, I liked your project from long times ago. Thank you for creating that project.

@maxisam
Copy link
Owner

maxisam commented Apr 18, 2019

@Ismaestro also could you try 4.0.0-beta.12. I think it will help on things like some images are not loaded properly

@Ismaestro
Copy link
Author

With that version while serving the app with ssr, I got this error:

> [email protected] serve:ssr /Users/iramos/WebstormProjects/angular7-example-app
> node dist/server

Node server listening on http://localhost:4000
/Users/iramos/WebstormProjects/angular7-example-app/dist/server.js:344
                        throw error;
                        ^

TypeError: Cannot read property 'src' of undefined
    at loadImage (/Users/iramos/WebstormProjects/angular7-example-app/dist/server.js:279342:27)
    at ProgressiveImageDirective.ngOnInit (/Users/iramos/WebstormProjects/angular7-example-app/dist/server.js:279694:13)
    at checkAndUpdateDirectiveInline (/Users/iramos/WebstormProjects/angular7-example-app/dist/server.js:26202:19)
    at checkAndUpdateNodeInline (/Users/iramos/WebstormProjects/angular7-example-app/dist/server.js:27466:20)
    at checkAndUpdateNode (/Users/iramos/WebstormProjects/angular7-example-app/dist/server.js:27428:16)

Serving the app with JIT goes fine.

:)

@maxisam
Copy link
Owner

maxisam commented Apr 18, 2019

Weird. That doesn't make any sense. There are only 2 changes between 9 and 12, 819dae7 and 717c266 I don't understand how could it work on 9 but not 12

@maxisam maxisam reopened this Apr 18, 2019
@Ismaestro
Copy link
Author

Yup so weird. You can reproduce the error just clone my project, upgrade the version, npm run build:ssr and npm run serve:ssr. You will see the error...

@maxisam
Copy link
Owner

maxisam commented Apr 18, 2019

I will try it sometime this week.

@rassrig
Copy link

rassrig commented Jan 30, 2020

I've also encountered an error while running with universal app

export '_window' (imported as 'i11') was not found in 'ngx-window-token'

"ngx-progressive-image-loader": "^3.0.2",
"ngx-window-token": "^2.0.1",
"tslib": "^1.10.0

Tried to recreate this with just angular and works fine.
Let me know if I missed something

@maxisam
Copy link
Owner

maxisam commented Jan 30, 2020

please try the latest beta version. 4.0.0-beta.15. I used it on production for a while already.

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

3 participants