DethAriel / ng-recaptcha

Angular component for Google reCAPTCHA
https://dethariel.github.io/ng-recaptcha/
MIT License
463 stars 122 forks source link

Standard Angular Standalone app giving NullInjectionError: R3InjectorError error #309

Closed KyleSmith0905 closed 7 months ago

KyleSmith0905 commented 8 months ago

Summary

I'm submitting a:

Description

I have a Angular 16 standalone component using ng-recaptcha.

However, I'm getting this error:

Uncaught (in promise): NullInjectorError: R3InjectorError(Standalone[SupportPage])[ReCaptchaV3Service -> InjectionToken recaptcha-v3-site-key -> InjectionToken recaptcha-v3-site-key -> InjectionToken recaptcha-v3-site-key]: 
  NullInjectorError: No provider for InjectionToken recaptcha-v3-site-key!
NullInjectorError: R3InjectorError(Standalone[SupportPage])[ReCaptchaV3Service -> InjectionToken recaptcha-v3-site-key -> InjectionToken recaptcha-v3-site-key -> InjectionToken recaptcha-v3-site-key]: 
  NullInjectorError: No provider for InjectionToken recaptcha-v3-site-key!

Demo

https://stackblitz.com/edit/ng-recaptcha-example-5nzbhq?file=src%2Fapp%2Fapp.component.ts

Lib versions:

MrKioZ commented 7 months ago

I have the same issue Im using angular 16.2.12

DethAriel commented 7 months ago

you have to move the providers appropriately. Check out this StackOverflow answer, or take a look at the fixed example.