Reference & Instance
For situations where the module has any mistakes or missing methods (I'm aware it has) you can now access both your elements instance and a reference to Stripe:
1
import { Component, OnInit } from '@angular/core';
2
3
import { StripeService } from 'ngx-stripe';
4
5
@Component({
6
selector: 'app-stripe-test',
7
templateUrl: 'stripe.html'
8
})
9
export class StripeTestComponent implements OnInit {
10
11
constructor(
12
private fb: FormBuilder,
13
private stripeSerivce: StripeService
14
) {}
15
16
ngOnInit() {
17
// this is equivalent to window.Stipe, but it make sure the module is loaded
18
const Stripe$: Observable<any> = this.stripeService.getStripeReference();
19
20
// this is a reference to the stripe elements object
21
const stripe = this.stripeService.getInstance();
22
}
23
}
Copied!
Last modified 1yr ago
Copy link