Monday, 14 February 2022

Renderer2.setProperty() doesn't update the value

I am trying to update the value using the rendered.setproperty() where value is updating the second time on listen event

these are the value that I am sending for the first time as empty in some widget

<ols-giftcard-payment-widget site-id="56711" customer-last-name="" jwt-token="abcd"></ols-giftcard-payment-widget>

here I want to update the customer-last-name as a dynamic value

import { Component, Renderer2 } from '@angular/core';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class AppComponent {
  name = 'Angular';
  constructor(private renderer: Renderer2) {}
  createRecaptchaContainer() {
    const recaptchaContainer = this.renderer.createElement(
      'ols-giftcard-payment-widget'
    );
    this.renderer.setProperty(recaptchaContainer, 'siteId', '56711');
    this.renderer.setProperty(
      recaptchaContainer,
      'jwtToken',
      'abcd'
    );
    let cardClickEvent = this.renderer.listen(
      recaptchaContainer,
      'addCard',
      (evt) => {
        this.renderer.setProperty(
          recaptchaContainer,
          'customerLastName',
          'anonymousLastName'
        );
        this.renderer.appendChild(
          document.getElementById('payment-widget'),
          recaptchaContainer
        );

        return recaptchaContainer;

        debugger;
      }
    );
    this.renderer.appendChild(
      document.getElementById('payment-widget'),
      recaptchaContainer
    );

    return recaptchaContainer;
  }

  ngOnInit(): void {
    this.createRecaptchaContainer();
  }
}
<div id="payment-widget"></div>

Here I am trying to add the customerLastname in this setProperty this.renderer.setProperty( recaptchaContainer, 'customerLastName', 'anonymousLastName' ); it is updating on the second click, not on the first click

please help me to find here where I am wrong in the implementation

Here is the link for stackblizt "https://ift.tt/mW4suGN"



from Renderer2.setProperty() doesn't update the value

No comments:

Post a Comment