I'm using NX environment to manage multiple projects and, as it doesn't have a default way to work with environments, I created a service that implements the environment variables and it's working as expected.
The issue for me is inside the libs. One of the libs I have is for checkout payment, which uses NgxStripe. This module requires the PublishKey, which I have stored in the environment variables that comes from a service.
So, right now my CheckoutModule looks like this:
@NgModule({
imports: [
CommonModule,
ReactiveFormsModule,
RouterModule.forChild(userRouting),
[...]
NgxStripeModule.forRoot(environment.stripe?.publishable_key),
[...]
],
})
But I wonder if there is a way for me to use the publish key from my environment service, which loads data from the app that is running, instead of this mock environment I created to use only on this module. Something like this:
@NgModule({
imports: [
CommonModule,
ReactiveFormsModule,
RouterModule.forChild(userRouting),
[...]
NgxStripeModule.forRoot(EnvironmentService.getValue().stripe.pk),
[...]
],
})
Does anyone knows a way to achieve this?
I do not have experience with
ngx-stripebut according to docs that should work:Usually you would put your service on deps but since it looks like static one you don't have to.