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

Is the library working in a standalone component? #80

Open
lmame opened this issue Mar 1, 2024 · 0 comments
Open

Is the library working in a standalone component? #80

lmame opened this issue Mar 1, 2024 · 0 comments

Comments

@lmame
Copy link

lmame commented Mar 1, 2024

Hi :)

I was using ng-hcaptcha on Angular 12 until now and it was working perfectly, I had an Angular component and a module for it where I was using it:
https://github.com/bmcsoftware/innovation-studio-developer/blob/main/22.1/test210500/bundle/src/main/webapp/libs/com-example-test210500/src/lib/view-components/captcha/runtime/captcha.module.ts#L9

@NgModule({
  imports: [CommonModule, NgHcaptchaModule.forRoot()],
  exports: [CaptchaComponent],
  declarations: [CaptchaComponent],
  entryComponents: [CaptchaComponent]
})

I tried to refactor the component with Angular 14 and change the Component to be a standalone component, so something like:

@Component({
  selector: 'com-example-test210500-com-example-test210500-captcha',
  templateUrl: './captcha.component.html',
  standalone: true,
  imports: [CommonModule, NgHcaptchaModule.forRoot()]
})

However this triggers an error during build:
In Webstorm:
TS2322: Type ModuleWithProviders<NgHcaptchaModule> is not assignable to type any[] | Type<any>

During build:

Error: libs/com-example-test210500/src/lib/view-components/captcha/runtime/captcha.component.ts:18:27 - error TS2322: Type 'ModuleWithProviders<NgHcaptchaModule>' is not assignable to type 'any[] | Type<any>'.
imports: [CommonModule, NgHcaptchaModule.forRoot()]

According to Angular I could use importProvidersFrom but in our use case. we are a Platform and we load dynamically those components, so we don't have access to boostrapapplication.

I was wondering if this was something on the radar?

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

1 participant