-
Notifications
You must be signed in to change notification settings - Fork 142
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
ERROR in Invalid provider for LazyLoadImageHooks. useClass cannot be undefined. #463
Comments
Same issue here |
i get the same issue. |
i got same issue.... help us |
um... I'm using it as version 7.1.0 until fix it. |
What version of Do you get this error under build time or in the browser console? Is it possible to create a small repo with this issue? I'm using Angular 9 in the example folder: https://github.com/tjoskar/ng-lazyload-image/blob/master/example/package.json and I can't see the issue there? And not in this code sandbox: https://codesandbox.io/s/lazy-load-image-with-httpclient-to538?file=/src/app/app.module.ts (for example). |
@tjoskar this error occured at build time . |
ERROR: Invalid provider for LazyLoadImageHooks. useClass cannot be undefined. An unhandled exception occurred: Invalid provider for LazyLoadImageHooks. useClass cannot be undefined. I have this error while building an angular library |
I can't reproduce this. I just created a new angular 9 app (9.1.9):
I then made the following changes: tjoskar/ng-lazyload-image-bugs@7fe50bd And run I need your help in order to fix this.
|
Try not to create an application but a library |
@emanuele-galeotti, I do not follow. Are you telling me that you are creating a library and that you want to use |
the above error occurs in my case when:
Can you ask to do this? |
Does the build fail when you build your library or when you build the application that is using your library? I did the following now:
There is the library: https://github.com/tjoskar/ng-lazyload-image-bugs/tree/master/463-invalid-provider-for-lazyLoadImageHook-libs And here is the changes I made: tjoskar/ng-lazyload-image-bugs@1bf60bc |
I understand if your projects are private and you cant share your code, but it would be to good help if you could create a small project where you can reproduce the error. |
it fails when I build the library, as soon as I can I try to share the code. |
i got same issue :( . i was add LAZY LOAD MODULE to child module |
i using Ionic 5, angular 9 . and try build to product we got that error |
same issue. try build app with ionic 5 and andular 9... |
I got this to compile by going back to the previous version: |
it worked.. thanks.... |
@Davei234 it works fine thanks |
I'm not able to reproduce this so I would be happy if anyone can create a project where this is reproduced.
Please let me know if anyone can share some code where you reproduce this. |
Do you have |
I'm building my UI library, I don't have ivy on because it's not accepted by npm |
It looks like version |
I got the same issue with angular 9 when I disabled IVY. |
Hi. The problem appeared when I deleted node_modules and lock file and ran npm install and the build again. Before this everything was working fine with latest 8.0.1 Ivy is enable. I went back to previous version (7.1.0) and it's working again. |
I have the same issue, and I have Ivy enabled.
Getting error |
Same error using angular 10, when try to extract the source language file. |
I'm only able to reproduce this when I disable Ivy. I did create an Angular 10 app but it was only when I disabled I have now published a new version that looks like it works with, and without, Ivy. Please try it out and see if it works for you: If you are using custom hooks you will need to update your code: import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { LazyLoadImageModule, IntersectionObserverHooks, Attributes } from 'ng-lazyload-image';
import { AppComponent } from './app.component';
class LazyLoadImageHooks extends IntersectionObserverHooks {
async loadImage({ imagePath }: Attributes): Promise<string> {
return await fetch(imagePath, {
headers: {
Authorization: 'Bearer ...',
},
})
.then((res) => res.blob())
.then((blob) => URL.createObjectURL(blob));
}
}
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, LazyLoadImageModule.forRoot(LazyLoadImageHooks)],
bootstrap: [AppComponent],
})
export class MyAppModule {} After: import { NgModule, Injectable } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { LazyLoadImageModule, IntersectionObserverHooks, Attributes, LAZYLOAD_IMAGE_HOOKS } from 'ng-lazyload-image';
import { AppComponent } from './app.component';
@Injectable()
export class LazyLoadImageHooks extends IntersectionObserverHooks {
async loadImage({ imagePath }: Attributes): Promise<string> {
return await fetch(imagePath, {
headers: {
Authorization: 'Bearer ...',
},
})
.then((res) => res.blob())
.then((blob) => URL.createObjectURL(blob));
}
}
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, LazyLoadImageModule],
providers: [{ provide: LAZYLOAD_IMAGE_HOOKS, useClass: LazyLoadImageHooks }],
bootstrap: [AppComponent],
})
export class MyAppModule {} |
I see this error in my angular 10 app with ivy. However compilation works fine, only the |
Upgrading to |
it worked |
This should be fixed in version 9.0.0 |
I got this error in an Angular9 project
The text was updated successfully, but these errors were encountered: