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

loadImage function doesn't work in standalone angular App #569

Open
rezaimn opened this issue May 3, 2024 · 1 comment
Open

loadImage function doesn't work in standalone angular App #569

rezaimn opened this issue May 3, 2024 · 1 comment

Comments

@rezaimn
Copy link

rezaimn commented May 3, 2024

I'm using Angular 17.3 and my app is completely standalone, so I don't have any ngModules. I want to use loadImage function to cancel the loading images when user changes the route or tab. I have imported the LazyLoadImageModule into my app component, also I have added the
{ provide: LAZYLOAD_IMAGE_HOOKS, useClass: LazyLoadImageHooks, deps: [HttpClient] }
to my appConfig providers, I'm using this class

@Injectable()
class LazyLoadImageHooks extends IntersectionObserverHooks {
  private http: HttpClient;

  constructor(http: HttpClient) {
    // You can inject what ever service you want here
    super();
    this.http = http;
  }

  loadImage({ imagePath }: Attributes): Observable<string> {
    console.log('YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY', imagePath);
    return this.http.get(imagePath, { responseType: 'blob' }).pipe(map((blob) => URL.createObjectURL(blob)));
  }
}

the console.log never executes.

I tried to add LazyLoadImageModule to appconfig providers using importProvidersFrom( but it doesn't work.

how should I do it.

if you could provide me a simple example using angular standalone and use loadImage to cancel the image load, it would be so nice

@tjoskar
Copy link
Owner

tjoskar commented Jun 5, 2024

Hi,
I have not used the standalone mode but I guess that is the future of Angular.

Unfortunately, I am not actively developing this library anymore, see: #570

But I would welcome help if you figure out how to use it in standalone mode.

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

2 participants