Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Angular - BUG in compoment StripePaymentResultComponent #8682


User avatar
1
denis.karovic created

Hello,

There is an error with this component. If getting payment result is not succesfull after the first attempt and the method controlAgain() needs to be called, there is en error with loosing scope.

Wrong implementation:

  controlAgain() {
        if (this.maxControlCount === 0) {
          return;
        }

        setTimeout(this.getPaymentResult, this.controlTimeout);                         // this makes it looses scope
        this.controlTimeout *= 2;
        this.maxControlCount--;
  }
  

Appropriate Implementation:

controlAgain() {
        if (this.maxControlCount === 0) {
          return;
        }

        setTimeout( () => {
            this.getPaymentResult();
        }, this.controlTimeout);                                                                    // this way scope is perserved
        this.controlTimeout *= 2;
        this.maxControlCount--;
  }

2 Answer(s)